--- libgender/fsh.cg 2004/10/05 11:25:19 1.10 +++ libgender/fsh.cg 2004/10/18 14:31:36 1.21 @@ -4,48 +4,38 @@ float3 LightVec : TEXCOORD1; float3 EyeVec : TEXCOORD2; float3 WorldNormal : TEXCOORD3; + float3 WorldView : TEXCOORD4; + float3 test1 : TEXCOORD5; + float3 test2 : TEXCOORD6; }; struct pixelOut { float4 col : COLOR; }; -pixelOut main(vertexOut IN) +pixelOut main(vertexOut IN, uniform sampler2D Texture) { - pixelOut OUT; // output of the pixel shader + pixelOut OUT; - float SpecExpon = 120; + half SpecExpon = 200; float4 LightColor = { 1, 1, 1, 1 }; + float4 diffuse_color = tex2D (Texture, IN.TexCoord.xy); - float3 n = IN.WorldNormal; - float3 v = IN.EyeVec; - float3 l = IN.LightVec; - - float r = reflect (-v, n); - float spec = pow (clamp (dot (l, r), 0, 1), SpecExpon); - float 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; + half3 Ln = normalize (IN.LightVec); + half3 Nn = normalize (IN.WorldNormal); + half3 Vn = normalize (IN.WorldView); + + half3 Hn = normalize (Ln + Vn); + half ldn = dot (Ln, Nn); + half hdn = dot (Hn, Nn); + + half4 litV = lit (ldn, hdn, SpecExpon); + half4 diffContrib = diffuse_color * ((litV.y + 0.3) * LightColor + glstate.lightmodel.ambient); + half4 specContrib = litV.y * litV.z * LightColor; + half4 result = diffContrib + specContrib; + //half4 result = diffuse_color * litV.y + LightColor * litV.z; OUT.col = result; return OUT; - */ }