ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/fsh.cg
(Generate patch)

Comparing libgender/fsh.cg (file contents):
Revision 1.9 by root, Tue Oct 5 11:06:06 2004 UTC vs.
Revision 1.15 by root, Wed Oct 6 09:41:48 2004 UTC

2 float4 HPosition : POSITION; 2 float4 HPosition : POSITION;
3 float4 TexCoord : TEXCOORD0; 3 float4 TexCoord : TEXCOORD0;
4 float3 LightVec : TEXCOORD1; 4 float3 LightVec : TEXCOORD1;
5 float3 EyeVec : TEXCOORD2; 5 float3 EyeVec : TEXCOORD2;
6 float3 WorldNormal : TEXCOORD3; 6 float3 WorldNormal : TEXCOORD3;
7 float3 WorldView : TEXCOORD4;
7}; 8};
8 9
9struct pixelOut { 10struct pixelOut {
10 float4 col : COLOR; 11 float4 col : COLOR;
11}; 12};
12 13
13pixelOut main(vertexOut IN) 14pixelOut main(vertexOut IN, uniform sampler2D Texture)
14{ 15{
15 pixelOut OUT; // output of the pixel shader 16 pixelOut OUT;
16 17
17 float SpecExpon = 120; 18 half SpecExpon = 200;
19 float4 AmbiColor = { 0.5, 0.5, 0.5, 1.0 };
18 float4 LightColor = { 1, 1, 1, 1 }; 20 float4 LightColor = { 1, 1, 1, 1 };
21 float4 diffuse_color = tex2D (Texture, IN.TexCoord.xy);
19 22
20 float3 Ln = IN.LightVec; 23 half3 Ln = normalize (IN.LightVec);
21 float3 Nn = IN.WorldNormal; 24 half3 Nn = normalize (IN.WorldNormal);
22 float3 Vn = IN.EyeVec; 25 half3 Vn = normalize (IN.WorldView);
26
27 half3 Hn = normalize (Ln + Vn);
28 half ldn = dot (Ln, Nn);
29 half hdn = dot (Hn, Nn);
23 30
24 float3 Hn = 0.5 * (Ln + Vn);
25 float ldn = dot (Ln, Nn);
26 float hdn = dot (Hn, Nn);
27
28 // specialized "lit" function computes weights for
29 // diffuse and specular parts:
30 float4 litV = lit (ldn, hdn, SpecExpon); 31 half4 litV = lit (ldn, hdn, SpecExpon);
31 float4 diffContrib = glstate.material.diffuse * (litV.y * LightColor + glstate.lightmodel.ambient); 32 //half4 diffContrib = glstate.material.diffuse * (litV.y * LightColor + glstate.lightmodel.ambient);
32 float4 specContrib = litV.y * litV.z * LightColor; 33 //half4 specContrib = litV.y * litV.z * LightColor;
33 float4 result = diffContrib + specContrib; 34 //half4 result = diffContrib + specContrib;
35 half4 result = diffuse_color * litV.y + LightColor * litV.z;
36 // half4 result = AmbiColor + glstate.material.diffuse * litV.y + LightColor * litV.z;
34 37
35 OUT.col = result; 38 OUT.col = result;
36 return OUT; 39 return OUT;
37} 40}
38 41

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines