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

Comparing libgender/fsh.cg (file contents):
Revision 1.1 by root, Tue Oct 5 06:47:47 2004 UTC vs.
Revision 1.9 by root, Tue Oct 5 11:06:06 2004 UTC

1// final pixel output: 1struct vertexOut {
2// data from pixel shader to frame buffer 2 float4 HPosition : POSITION;
3 float4 TexCoord : TEXCOORD0;
4 float3 LightVec : TEXCOORD1;
5 float3 EyeVec : TEXCOORD2;
6 float3 WorldNormal : TEXCOORD3;
7};
3 8
4struct pixelOut { 9struct pixelOut {
5 float4 col : COLOR; 10 float4 col : COLOR;
6}; 11};
7// pixel shader 12
8pixelOut mainPS(vertexOut IN, // input from vertex shade 13pixelOut main(vertexOut IN)
9 uniform float SpecExpon, // constant parameters fro
10 uniform float4 AmbiColor, // application
11 uniform float4 SurfColor,
12 uniform float4 LightColor
13 )
14{ 14{
15 pixelOut OUT; // output of the pixel shader 15 pixelOut OUT; // output of the pixel shader
16
17 float SpecExpon = 120;
18 float4 LightColor = { 1, 1, 1, 1 };
19
16 float3 Ln = normalize(IN.LightVec); 20 float3 Ln = IN.LightVec;
17 float3 Nn = normalize(IN.WorldNormal); 21 float3 Nn = IN.WorldNormal;
18 float3 Vn = normalize(IN.WorldView); 22 float3 Vn = IN.EyeVec;
19 float3 Hn = normalize(Vn + 23
20 // scalar product between light and normal vectors: 24 float3 Hn = 0.5 * (Ln + Vn);
21 float ldn = dot(Ln,Nn); 25 float ldn = dot (Ln, Nn);
22 // scalar product between halfway and normal vectors:
23 float hdn = dot(Hn,Nn); 26 float hdn = dot (Hn, Nn);
27
24 // specialized "lit" function computes weights for 28 // specialized "lit" function computes weights for
25 // diffuse and specular parts: 29 // diffuse and specular parts:
26 float4 litV = lit(ldn,hdn,SpecExpon); 30 float4 litV = lit (ldn, hdn, SpecExpon);
27 float4 diffContrib = 31 float4 diffContrib = glstate.material.diffuse * (litV.y * LightColor + glstate.lightmodel.ambient);
28 SurfColor * ( litV.y * LightColor + AmbiColor);
29 float4 specContrib = litV.y*litV.z * LightColor; 32 float4 specContrib = litV.y * litV.z * LightColor;
30 // sum of diffuse and specular contributions:
31 float4 result = diffContrib + specContrib; 33 float4 result = diffContrib + specContrib;
34
32 OUT.col = result; 35 OUT.col = result;
33 return OUT; // output of pixel shader 36 return OUT;
34} 37}
35 38

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines