!!ARBfp1.0 # Texunit 0: bump map and bump map coordinates # Texunit 1: first row of tangent space -> object space rotation matrix # Texunit 2: second row of tangent space -> object space rotation matrix # Texunit 3: third row of tangent space -> object space rotation matrix # Texunit 4: view vector in obj space (unnormalized) # Texunit 5: bound to reflection environment cube map. # Primary color: unused 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 R, N, V, rotVec1, rotVec2, rotVec3, rotatedNormal, reflectedView, finalColor; TEX N, fragment.texcoord[0], texture[0], 2D; # Prepare direction vectors. # SUB N, N, 0.5; # Scale and bias bumped normal ADD N, N, N; MOV V, fragment.texcoord[4]; DP3 V.a, V, V; # Normalize view vector. RSQ V.a, V.a; # MUL V, V, V.a; # # Prepare rotation vector (from tangent space to obj space) # MOV rotVec1, fragment.texcoord[1]; DP3 rotVec1.a, rotVec1, rotVec1; # Normalize rotation vector1. RSQ rotVec1.a, rotVec1.a; # MUL rotVec1, rotVec1, rotVec1.a; # MOV rotVec2, fragment.texcoord[2]; DP3 rotVec2.a, rotVec2, rotVec2; # Normalize rotation vector2. RSQ rotVec2.a, rotVec2.a; # MUL rotVec2, rotVec2, rotVec2.a; # MOV rotVec3, fragment.texcoord[3]; DP3 rotVec3.a, rotVec3, rotVec3; # Normalize rotation vector3. RSQ rotVec3.a, rotVec3.a; # MUL rotVec3, rotVec3, rotVec3.a; # # Convert the tangent space normal into object space. # DP3 rotatedNormal.x, N, rotVec1; DP3 rotatedNormal.y, N, rotVec2; DP3 rotatedNormal.z, N, rotVec3; # compute R = 2N (N . V) - V. # DP3 reflectedView.x, rotatedNormal, V; # N.V MUL reflectedView.x, reflectedView.x, 2; # 2(N.V) MUL reflectedView, reflectedView.x, rotatedNormal; # 2N(N.V) SUB reflectedView, reflectedView, V; TEX finalColor, reflectedView, texture[5], CUBE; MOV outColor, finalColor; END