struct vertexOut { float4 HPosition : POSITION; float4 TexCoord : TEXCOORD0; float3 LightVec : TEXCOORD1; float3 EyeVec : TEXCOORD2; float3 WorldNormal : TEXCOORD3; }; struct pixelOut { float4 col : COLOR; }; pixelOut main(vertexOut IN) { pixelOut OUT; // output of the pixel shader float SpecExpon = 120; float4 LightColor = { 1, 1, 1, 1 }; half3 n = IN.WorldNormal; half3 v = IN.EyeVec; half3 l = IN.LightVec; half r = reflect (-v, n); half spec = pow (clamp (dot (l, r), 0, 1), SpecExpon); half diff = clamp (dot (n, l), 0.0, 1); OUT.col = glstate.material.diffuse * diff + LightColor * spec; return OUT; /* float3 Ln = normalize (IN.LightVec); float3 Nn = normalize (IN.WorldNormal); float3 Vn = normalize (IN.EyeVec); float3 Hn = 0.5 * (Ln + Vn); float ldn = dot (Ln, Nn); float hdn = dot (Hn, Nn); // specialized "lit" function computes weights for // diffuse and specular parts: float4 litV = lit (ldn, hdn, SpecExpon); float4 diffContrib = glstate.material.diffuse * (litV.y * LightColor + glstate.lightmodel.ambient); float4 specContrib = litV.y * litV.z * LightColor; float4 result = diffContrib + specContrib; OUT.col = result; return OUT; */ }