!!ARBfp1.0 # =============================================== # Diffuse Phong with transparency encoded in RGB. # =============================================== # # Bind and define the diffuse fragment shader. # This shader expects the following inputs: # # Texunit 0: projective light texture & generated texture coordinates # Texunit 1: bump map and bump map coordinates # Texunit 2: unused # Texunit 3: transparency in RGB / opacity in alpha # Texunit 4: light (L) vector in tangent space # Texunit 5: base color texture coordinates # Primary color: light color # PARAM half = { 0.5, 0.5, 0.5, 0.5 }; PARAM kd = program.local[0]; ATTRIB primaryColor = fragment.color.primary; # Fragment outputs OUTPUT outColor = result.color; TEMP finalColor, N, L, baseColor, NdotL, transpTexture; # Compute N dot L. # TEX N, fragment.texcoord[1], texture[1], 2D; SUB N, N, half; # Scale and bias bumped normal ADD N, N, N; #TEX L, fragment.texcoord[4], texture[4], CUBE; #SUB L, L, half; # Scale and bias light vector #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; # DP3_SAT NdotL, L, N; # NdotL = N.L TXP finalColor, fragment.texcoord[0], texture[0], 2D; # fetch projected light color. TEX baseColor, fragment.texcoord[5], texture[5], 2D; TEX transpTexture, fragment.texcoord[3], texture[3], 2D; MUL finalColor, finalColor, NdotL; MUL finalColor, finalColor, baseColor; MUL finalColor, finalColor, primaryColor; # finalColor *= mipmapped normal attenuation factor. # (This is suggested by Kilgard... only affects the diffuse) MUL finalColor, finalColor, N.a; # multiply by opacity alpha. MUL finalColor, finalColor, transpTexture.a; MUL finalColor, finalColor, kd.a; MOV outColor, finalColor; END