ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libgender/fsh.cg
Revision: 1.1
Committed: Tue Oct 5 06:47:47 2004 UTC (21 years, 11 months ago) by root
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

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