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.17 by root, Wed Oct 6 14:37:34 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 float3 WorldView : TEXCOORD4;
8 float3 test1 : TEXCOORD5;
9 float3 test2 : TEXCOORD6;
10};
3 11
4struct pixelOut { 12struct pixelOut {
5 float4 col : COLOR; 13 float4 col : COLOR;
6}; 14};
7// pixel shader 15
8pixelOut mainPS(vertexOut IN, // input from vertex shade 16pixelOut main(vertexOut IN, uniform sampler2D Texture)
9 uniform float SpecExpon, // constant parameters fro
10 uniform float4 AmbiColor, // application
11 uniform float4 SurfColor,
12 uniform float4 LightColor
13 )
14{ 17{
15 pixelOut OUT; // output of the pixel shader 18 pixelOut OUT;
19
20 half SpecExpon = 200;
21 float4 AmbiColor = { 0.1, 0.1, 0.1, 1.0 };
22 float4 LightColor = { 1, 1, 1, 1 };
23 float4 diffuse_color = tex2D (Texture, IN.TexCoord.xy);
24
16 float3 Ln = normalize(IN.LightVec); 25 half3 Ln = normalize (IN.LightVec);
17 float3 Nn = normalize(IN.WorldNormal); 26 half3 Nn = normalize (IN.WorldNormal);
18 float3 Vn = normalize(IN.WorldView); 27 half3 Vn = normalize (IN.WorldView);
19 float3 Hn = normalize(Vn + 28
20 // scalar product between light and normal vectors: 29 half3 Hn = normalize (Ln + Vn);
21 float ldn = dot(Ln,Nn); 30 half ldn = dot (Ln, Nn);
22 // scalar product between halfway and normal vectors:
23 float hdn = dot(Hn,Nn); 31 half hdn = dot (Hn, Nn);
24 // specialized "lit" function computes weights for 32
25 // diffuse and specular parts:
26 float4 litV = lit(ldn,hdn,SpecExpon); 33 half4 litV = lit (ldn, hdn, SpecExpon);
27 float4 diffContrib = 34 half4 diffContrib = diffuse_color * (litV.y * LightColor + glstate.lightmodel.ambient);
28 SurfColor * ( litV.y * LightColor + AmbiColor);
29 float4 specContrib = litV.y*litV.z * LightColor; 35 half4 specContrib = litV.y * litV.z * LightColor;
30 // sum of diffuse and specular contributions:
31 float4 result = diffContrib + specContrib; 36 half4 result = diffContrib + specContrib;
37 //half4 result = diffuse_color * litV.y + LightColor * litV.z;
38
32 OUT.col = result; 39 OUT.col = result;
33 return OUT; // output of pixel shader 40 return OUT;
34} 41}
35 42

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines