1!!ARBvp1.0
2
3# Compute the surface space light vectors for diffuse bump mapping
4
5ATTRIB iPos          = vertex.position;
6ATTRIB iNormal       = vertex.normal;
7ATTRIB iTangent      = vertex.attrib[6];
8ATTRIB iTex0         = vertex.texcoord[0];
9ATTRIB iTex1         = vertex.texcoord[1];
10PARAM  mvp[4]        = { state.matrix.mvp };
11PARAM  lightDir      = program.env[0];
12PARAM  qtr           = 0.25;
13PARAM  half          = 0.5;
14PARAM  one           = 1;
15OUTPUT oPos          = result.position;
16OUTPUT oColor        = result.color;
17OUTPUT oTex0         = result.texcoord[0];
18OUTPUT oTex1         = result.texcoord[1];
19
20TEMP   binormal;
21TEMP   t;
22TEMP   light_surf;
23
24# Transform the vertex by the modelview matrix
25DP4   oPos.x, mvp[0], iPos;
26DP4   oPos.y, mvp[1], iPos;
27DP4   oPos.z, mvp[2], iPos;
28DP4   oPos.w, mvp[3], iPos;
29
30# Compute the binormal--cross product of tangent and normal
31MOV   t, iTangent;
32MUL   binormal, iNormal.zxyw, t.yzxw;
33MAD   binormal, iNormal.yzxw, t.zxyw, -binormal;
34
35# Normalization should not be necessary
36#DP3   binormal.w, binormal, binormal;
37#RSQ   binormal.w, binormal.w;
38#MUL   binormal.xyz, binormal, binormal.w;
39
40# Transform the light direction from object space into surface space
41DP3   light_surf.x, iTangent, lightDir;
42DP3   light_surf.y, -binormal, lightDir;
43DP3   light_surf.z, iNormal, lightDir;
44
45# Compress the light direction to fit in the primary color and output it
46MAD   oColor, light_surf, qtr, half;
47MOV   oColor.w, one.w;
48
49# Output the texture
50MOV   oTex0, iTex0;
51MOV   oTex1, iTex1;
52
53END
54
55