?/TD> |
Microsoft DirectX 9.0 |
The syntax for a shader declaration is shown here.
This example uses a single stream. Data is provided to four registers, with position, normal, and two sets of texture coordinate data.
technique Assembly_Level_VertexShader { pass P0 { // Vertex state VertexShaderConstant4[0] = (matWorld); VertexShaderConstant4[4] = (matViewProj); VertexShaderConstant1[13] = {vecLightColor}; VertexShaderConstant1[16] = {vecLightDir}; VertexShader = asm { vs_1_1 dcl_position v0 dcl_normal v3 dcl_texcoord v7 dcl_texcoord v8 m4x4 oPos, v0, c4 // Transform point to projection space. m3x3 r0,v3,c0 // Transform normal to world space, // put result into r0. dp3 r0,r0,-c16 // Dot product against light, r0 has lighting // constant in x, y, and z components (r,g,b). mul r0,r0,c13 // Modulate against diffuse light color. mov oD0,r0 // Put into diffuse color output. } } };