ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/fsh.cg
Revision: 1.11
Committed: Tue Oct 5 11:27:11 2004 UTC (19 years, 8 months ago) by root
Branch: MAIN
Changes since 1.10: +6 -6 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 half3 n = IN.WorldNormal;
21 half3 v = IN.EyeVec;
22 half3 l = IN.LightVec;
23
24 half r = reflect (-v, n);
25 half spec = pow (clamp (dot (l, r), 0, 1), SpecExpon);
26 half 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);
43 float4 diffContrib = glstate.material.diffuse * (litV.y * LightColor + glstate.lightmodel.ambient);
44 float4 specContrib = litV.y * litV.z * LightColor;
45 float4 result = diffContrib + specContrib;
46
47 OUT.col = result;
48 return OUT;
49 */
50 }
51