ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/fsh.cg
Revision: 1.8
Committed: Tue Oct 5 10:28:49 2004 UTC (19 years, 8 months ago) by root
Branch: MAIN
Changes since 1.7: +19 -22 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 struct vertexOut {
2 float4 HPosition : POSITION;
3 float4 TexCoord : TEXCOORD0;
4 float3 LightVec : TEXCOORD1;
5 float3 EyeVec : TEXCOORD2;
6 float3 WorldNormal : TEXCOORD3;
7 };
8
9 struct pixelOut {
10 float4 col : COLOR;
11 };
12
13 pixelOut main(vertexOut IN)
14 {
15 pixelOut OUT; // output of the pixel shader
16
17 float SpecExpon = 120;
18 float4 LightColor = { 1, 1, 1, 1 };
19
20 float3 Ln = IN.LightVec;
21 float3 Nn = IN.WorldNormal;
22 float3 Vn = IN.EyeVec;
23
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 float4 diffContrib = glstate.material.diffuse * (litV.y * LightColor + glstate.lightmodel.ambient);
32 float4 specContrib = litV.y * litV.z * LightColor;
33 float4 result = diffContrib + specContrib;
34
35 OUT.col = result;
36 return OUT; // output of pixel shader
37 }
38