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.12 by root, Wed Oct 6 00:22:42 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)
14{ 15{
15 pixelOut OUT; // output of the pixel shader 16 pixelOut OUT;
16 17
17 float SpecExpon = 120; 18 half SpecExpon = 200;
18 float4 LightColor = { 1, 1, 1, 1 }; 19 float4 LightColor = { 1, 1, 1, 1 };
19 20
20 float3 Ln = IN.LightVec; 21 half3 Ln = normalize (IN.LightVec);
21 float3 Nn = IN.WorldNormal; 22 half3 Nn = normalize (IN.WorldNormal);
22 float3 Vn = IN.EyeVec; 23 half3 Vn = normalize (IN.WorldView);
23 24
24 float3 Hn = 0.5 * (Ln + Vn); 25 half3 Hn = normalize (Ln + Vn);
25 float ldn = dot (Ln, Nn); 26 half ldn = dot (Ln, Nn);
26 float hdn = dot (Hn, Nn); 27 half hdn = dot (Hn, Nn);
27 28
28 // specialized "lit" function computes weights for 29 // specialized "lit" function computes weights for
29 // diffuse and specular parts: 30 // 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;
34 35
35 OUT.col = result; 36 OUT.col = result;
36 return OUT; 37 return OUT;
37} 38}
38 39

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines