1!!ARBvp1.0 2 3# Compute the diffuse light from two sources plus a haze effect 4 5ATTRIB iPos = vertex.position; 6ATTRIB iNormal = vertex.normal; 7ATTRIB iTex0 = vertex.texcoord[0]; 8PARAM mvp[4] = { state.matrix.mvp }; 9PARAM eyePos = program.env[1]; 10PARAM lightDir0 = program.env[0]; 11PARAM diffuse0 = program.env[2]; 12PARAM lightDir1 = program.env[18]; 13PARAM diffuse1 = program.env[19]; 14PARAM ambient = program.env[5]; 15PARAM zero = 0; 16PARAM one = 1; 17OUTPUT oPos = result.position; 18OUTPUT oColor = result.color; 19OUTPUT oTex0 = result.texcoord[0]; 20OUTPUT oFog = result.fogcoord; 21 22TEMP diffuseFactor; 23TEMP diffuseColor; 24TEMP hazeFactor; 25TEMP eyeVec; 26 27# Transform the vertex by the modelview matrix 28DP4 oPos.x, mvp[0], iPos; 29DP4 oPos.y, mvp[1], iPos; 30DP4 oPos.z, mvp[2], iPos; 31DP4 oPos.w, mvp[3], iPos; 32 33# Get the vector from the eye to the vertex 34SUB eyeVec, eyePos, iPos; 35 36# Normalize it 37DP3 eyeVec.w, eyeVec, eyeVec; 38RSQ eyeVec.w, eyeVec.w; 39MUL eyeVec, eyeVec, eyeVec.w; 40 41# Compute the illumination from the first light source 42DP3 diffuseFactor, iNormal, lightDir0; 43MAX diffuseFactor, diffuseFactor, zero; 44MAD diffuseColor, diffuse0, diffuseFactor, ambient; 45 46# Haze 47DP3 diffuseFactor.y, iNormal, eyeVec; 48SUB diffuseFactor.y, one, diffuseFactor.y; 49MUL hazeFactor.x, diffuseFactor.x, diffuseFactor.y; 50 51# Compute the illumination from the second light source 52DP3 diffuseFactor, iNormal, lightDir1; 53MAX diffuseFactor, diffuseFactor, zero; 54MAD diffuseColor, diffuse1, diffuseFactor, diffuseColor; 55 56# Haze 57DP3 diffuseFactor.y, iNormal, eyeVec; 58SUB diffuseFactor.y, one, diffuseFactor.y; 59MAD hazeFactor.x, diffuseFactor.x, diffuseFactor.y, hazeFactor.x; 60 61# Output the texture 62MOV oTex0, iTex0; 63# Output the primary color 64MOV oColor, diffuseColor; 65MOV oFog.x, hazeFactor; 66 67END 68 69