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

Comparing libgender/fsh.cg (file contents):
Revision 1.10 by root, Tue Oct 5 11:25:19 2004 UTC vs.
Revision 1.21 by root, Mon Oct 18 14:31:36 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;
8 float3 test1 : TEXCOORD5;
9 float3 test2 : TEXCOORD6;
7}; 10};
8 11
9struct pixelOut { 12struct pixelOut {
10 float4 col : COLOR; 13 float4 col : COLOR;
11}; 14};
12 15
13pixelOut main(vertexOut IN) 16pixelOut main(vertexOut IN, uniform sampler2D Texture)
14{ 17{
15 pixelOut OUT; // output of the pixel shader 18 pixelOut OUT;
16 19
17 float SpecExpon = 120; 20 half SpecExpon = 200;
18 float4 LightColor = { 1, 1, 1, 1 }; 21 float4 LightColor = { 1, 1, 1, 1 };
22 float4 diffuse_color = tex2D (Texture, IN.TexCoord.xy);
19 23
20 float3 n = IN.WorldNormal; 24 half3 Ln = normalize (IN.LightVec);
21 float3 v = IN.EyeVec; 25 half3 Nn = normalize (IN.WorldNormal);
22 float3 l = IN.LightVec; 26 half3 Vn = normalize (IN.WorldView);
27
28 half3 Hn = normalize (Ln + Vn);
29 half ldn = dot (Ln, Nn);
30 half hdn = dot (Hn, Nn);
23 31
24 float r = reflect (-v, n);
25 float spec = pow (clamp (dot (l, r), 0, 1), SpecExpon);
26 float diff = clamp (dot (n, l), 0.0, 1);
27
28 OUT.col = glstate.material.diffuse * diff + LightColor * spec;
29 return OUT;
30
31 /*
32 float3 Ln = normalize (IN.LightVec);
33 float3 Nn = normalize (IN.WorldNormal);
34 float3 Vn = normalize (IN.EyeVec);
35
36 float3 Hn = 0.5 * (Ln + Vn);
37 float ldn = dot (Ln, Nn);
38 float hdn = dot (Hn, Nn);
39
40 // specialized "lit" function computes weights for
41 // diffuse and specular parts:
42 float4 litV = lit (ldn, hdn, SpecExpon); 32 half4 litV = lit (ldn, hdn, SpecExpon);
43 float4 diffContrib = glstate.material.diffuse * (litV.y * LightColor + glstate.lightmodel.ambient); 33 half4 diffContrib = diffuse_color * ((litV.y + 0.3) * LightColor + glstate.lightmodel.ambient);
44 float4 specContrib = litV.y * litV.z * LightColor; 34 half4 specContrib = litV.y * litV.z * LightColor;
45 float4 result = diffContrib + specContrib; 35 half4 result = diffContrib + specContrib;
36 //half4 result = diffuse_color * litV.y + LightColor * litV.z;
46 37
47 OUT.col = result; 38 OUT.col = result;
48 return OUT; 39 return OUT;
49 */
50} 40}
51 41

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines