--- libgender/fsh.cg 2004/10/05 10:28:49 1.8 +++ libgender/fsh.cg 2004/10/10 02:40:18 1.19 @@ -4,35 +4,39 @@ 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 AmbiColor = { 0.9, 0.9, 0.9, 1.0 }; float4 LightColor = { 1, 1, 1, 1 }; + float4 diffuse_color = tex2D (Texture, IN.TexCoord.xy); - float3 Ln = IN.LightVec; - float3 Nn = IN.WorldNormal; - float3 Vn = 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.8) * 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; // output of pixel shader + return OUT; }