ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/cvsroot/libgender/fsh.cg
Revision: 1.2
Committed: Tue Oct 5 07:09:17 2004 UTC (21 years, 11 months ago) by root
Branch: MAIN
Changes since 1.1: +9 -1 lines
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 root 1.2 struct vertexOut {
4     float4 HPosition : POSITION;
5     float4 TexCoord : TEXCOORD0;
6     float3 LightVec : TEXCOORD1;
7     float3 WorldNormal : TEXCOORD2;
8     float3 WorldPos : TEXCOORD3;
9     float3 WorldView : TEXCOORD4;
10     };
11 root 1.1
12     struct pixelOut {
13     float4 col : COLOR;
14     };
15     // pixel shader
16 root 1.2 pixelOut main(vertexOut IN, // input from vertex shade
17 root 1.1 uniform float SpecExpon, // constant parameters fro
18     uniform float4 AmbiColor, // application
19     uniform float4 SurfColor,
20     uniform float4 LightColor
21     )
22     {
23     pixelOut OUT; // output of the pixel shader
24     float3 Ln = normalize(IN.LightVec);
25     float3 Nn = normalize(IN.WorldNormal);
26     float3 Vn = normalize(IN.WorldView);
27     float3 Hn = normalize(Vn +
28     // scalar product between light and normal vectors:
29     float ldn = dot(Ln,Nn);
30     // scalar product between halfway and normal vectors:
31     float hdn = dot(Hn,Nn);
32     // specialized "lit" function computes weights for
33     // diffuse and specular parts:
34     float4 litV = lit(ldn,hdn,SpecExpon);
35     float4 diffContrib =
36     SurfColor * ( litV.y * LightColor + AmbiColor);
37     float4 specContrib = litV.y*litV.z * LightColor;
38     // sum of diffuse and specular contributions:
39     float4 result = diffContrib + specContrib;
40     OUT.col = result;
41     return OUT; // output of pixel shader
42     }
43