!!ARBfp1.0 # Texunit 0: projective light texture & generated texture coordinates # Texunit 1: bump map and bump map coordinates # Texcoord 2: view (V) vector in tangent space # Texunit 3: N.H^k map # Texcoord 4: light (L) vector in tangent space # Texunit 5: specular color/exponent coordinates # Primary color: light color PARAM half = { 0.5, 0.5, 0.5, 0.5 }; PARAM one = { 1.0, 1.0, 1.0, 1.0 }; # Fragment outputs OUTPUT outColor = result.color; TEMP projLightColor, R, L, N, V, RdotVpowK, specColor, finalColor; TXP projLightColor, fragment.texcoord[0], texture[0], 2D; TEX N, fragment.texcoord[1], texture[1], 2D; TEX specColor, fragment.texcoord[5], texture[5], 2D; # Prepare direction vectors. # SUB N, N, 0.5; # Scale and bias bumped normal ADD N, N, N; #TEX V, fragment.texcoord[2], texture[2], CUBE; #SUB V, V, 0.5; # Scale and bias view direction #ADD V, V, V; MOV V, fragment.texcoord[2]; DP3 V.a, V, V; # Normalize view vector using math instead of normalization cube map. RSQ V.a, V.a; # MUL V, V, V.a; # #TEX L, fragment.texcoord[4], texture[4], CUBE; #SUB L, L, 0.5; # Scale and bias light direction #ADD L, L, L; MOV L, fragment.texcoord[4]; DP3 L.a, L, L; # Normalize light vector using math instead of normalization cube map. RSQ L.a, L.a; # MUL L, L, L.a; # # compute R = 2N (N . L) - L. DP3 R.x, N, L; # N.L MUL R.x, R.x, 2; # 2(N.L) MUL R, R.x, N; # 2N(N.L) SUB R, R, L; DP3 RdotVpowK.r, R, V; # R.V MUL RdotVpowK.g, specColor.a, 0.5; # (u,v) = (R.V, k) TEX RdotVpowK, RdotVpowK, texture[3], 2D; # RdotVpowK = R.V ^ k # finalColor = (R.V)^k * projective light color. MUL finalColor, RdotVpowK.r, projLightColor; # finalColor *= constant light color MUL finalColor, finalColor, fragment.color.primary; # finalColor *= specular color. MUL finalColor, finalColor, specColor; MOV outColor, finalColor; END