| Microsoft DirectX 8.1 (C++) |
This example is from exercise 1.
// Definition of the vertex shader, declarations then assembly.
VertexShader =
decl
{
stream 0;
float v0[3]; // Position
float v3[3]; // Normal
float v7[3]; // Texture Coord1
float v8[3]; // Texture coord2
}
asm
{
vs.1.1 // version number
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 now 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
};