!!ARBvp1.0 ATTRIB normal = vertex.normal; ATTRIB tangent = vertex.attrib[0]; PARAM mvp[4] = {state.matrix.mvp}; PARAM camera = program.env[0]; PARAM light = program.env[1]; TEMP bitangent, vdir, halfway, temp; # Transform vertex DP4 result.position.x, mvp[0], vertex.position; DP4 result.position.y, mvp[1], vertex.position; DP4 result.position.z, mvp[2], vertex.position; DP4 result.position.w, mvp[3], vertex.position; # B = (N x T) * T.w XPD bitangent, normal, tangent; MUL bitangent, bitangent, tangent.w; # Compute normalized V ADD view, camera, -vertex.position; DP3 temp, view, view; RSQ temp, temp.x; MUL view, view, temp; # Compute normalized H ADD halfway, view, light; DP3 temp, halfway, halfway; RSQ temp, temp.x; MUL halfway, halfway, temp; # Transform L into tangent space DP3 result.texcoord[2].x, tangent, light; DP3 result.texcoord[2].y, bitangent, light; DP3 result.texcoord[2].z, normal, light; # Transform H into tangent space DP3 result.texcoord[3].x, tangent, halfway; DP3 result.texcoord[3].y, bitangent, halfway; DP3 result.texcoord[3].z, normal, halfway; # Copy texture coords MOV result.texcoord[0], vertex.texcoord[0]; MOV result.texcoord[1], vertex.texcoord[1]; END