1!!ARBvp1.0
2
3# Night texture lighting
4
5ATTRIB iPos          = vertex.position;
6ATTRIB iNormal       = vertex.normal;
7ATTRIB iTex0         = vertex.texcoord[0];
8PARAM  mvp[4]        = { state.matrix.mvp };
9PARAM  lightDir      = program.env[0];
10PARAM  diffuse       = program.env[2];
11PARAM  zeroVec       = { 0, 0, 0, 0 };
12PARAM  one           = 1;
13OUTPUT oPos          = result.position;
14OUTPUT oColor        = result.color;
15OUTPUT oTex0         = result.texcoord[0];
16
17TEMP   diffuseFactor;
18
19# Transform the vertex by the modelview matrix
20DP4   oPos.x, mvp[0], iPos;
21DP4   oPos.y, mvp[1], iPos;
22DP4   oPos.z, mvp[2], iPos;
23DP4   oPos.w, mvp[3], iPos;
24
25# Compute the diffuse light component
26DP3   diffuseFactor, iNormal, lightDir;
27# Clamp the diffuse component to zero
28MAX   diffuseFactor, diffuseFactor, zeroVec;
29
30# Use the fourth power of L dot N to create a sharper division between
31# the lit and unlit sides of the planet.
32ADD   diffuseFactor, one, -diffuseFactor;
33MUL   diffuseFactor, diffuseFactor, diffuseFactor;
34MAD   diffuseFactor, diffuseFactor, -diffuseFactor, one;
35
36# Output the texture
37MOV   oTex0, iTex0;
38# Output the primary color
39MUL   oColor, diffuse, diffuseFactor;
40
41END
42
43