; Transforms a vertex to homogenoeous clip space ; and lights it with a single directional light in ; world space, then outputs a texture coordinate. ; - 28 instructions ; Note that negative output colors will be clamped ; by the implicit 0-1 clamp after the shader vs.1.1 ; get matrix palette index 1 mov a0.x, v3.y dp4 r2.x, v0, c[a0.x+0] dp4 r2.y, v0, c[a0.x+1] dp4 r2.z, v0, c[a0.x+2] ; get matrix palette index 2 mov a0.x, v3.z dp4 r3.x, v0, c[a0.x+0] dp4 r3.y, v0, c[a0.x+1] dp4 r3.z, v0, c[a0.x+2] ; get matrix palette index 0 - do this last so a0 is loaded with index 0 mov a0.x, v3.x dp4 r1.x, v0, c[a0.x+0] dp4 r1.y, v0, c[a0.x+1] dp4 r1.z, v0, c[a0.x+2] mov r1.w, v0.w ; multiply and add weights mul r1.xyz, r1.xyz, v2.xxx mad r1.xyz, r2.xyz, v2.yyy, r1.xyz mad r1.xyz, r3.xyz, v2.zzz, r1.xyz ; Transform to clip space dp4 oPos.x, r1, c92 dp4 oPos.y, r1, c93 dp4 oPos.z, r1, c94 dp4 oPos.w, r1, c95 ; lets rotate the normal by the main matrix - use dp3 - don't add on offsets! dp3 r1.x, v1, c[a0.x+0] dp3 r1.y, v1, c[a0.x+1] dp3 r1.z, v1, c[a0.x+2] dp3 r0.x, r1, c89 ; Dot normal with light direction in model space max r0.x, r0.x, c88.x ; zero out negative values ; Calculate color intensity mul r0, r0.xxxx, c90 ; Add on ambience add oD0, r0, c91 ; Output texture coordinates mov oT0, v4 ; compute SPECULAR part ; Dot normal with halfway vector ;dp3 r1, v1, c5 ;max r1, r1, c7.x ; zero out negative values; ; ; raise it to the specular index ;mov r1.w, c7.z ;lit r2, r1 ; ; multiply specular component by material color and ; add the diffuse color ;mad r1, r2.z, r5, r0 ; ; multiply light color with material color ;mul oD0, r1, c10