ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/fsh.cg
(Generate patch)

Comparing libgender/fsh.cg (file contents):
Revision 1.2 by root, Tue Oct 5 07:09:17 2004 UTC vs.
Revision 1.3 by root, Tue Oct 5 07:35:26 2004 UTC

10}; 10};
11 11
12struct pixelOut { 12struct pixelOut {
13 float4 col : COLOR; 13 float4 col : COLOR;
14}; 14};
15
15// pixel shader 16// pixel shader
16pixelOut main(vertexOut IN, // input from vertex shade 17pixelOut main(vertexOut IN // input from vertex shade
17 uniform float SpecExpon, // constant parameters fro 18 //uniform float SpecExpon, // constant parameters fro
18 uniform float4 AmbiColor, // application 19 //uniform float4 AmbiColor, // application
19 uniform float4 SurfColor, 20 //uniform float4 SurfColor,
20 uniform float4 LightColor 21 //uniform float4 LightColor
21 ) 22 )
22{ 23{
24 float SpecExpon = 100;
25 float4 AmbiColor = { 0.5, 0, 0, 1 };
26 float4 SurfColor = { 0, 0.5, 0, 1 };
27 float4 LightColor = { 1, 1, 1, 1 };
28
23 pixelOut OUT; // output of the pixel shader 29 pixelOut OUT; // output of the pixel shader
24 float3 Ln = normalize(IN.LightVec); 30 float3 Ln = normalize(IN.LightVec);
25 float3 Nn = normalize(IN.WorldNormal); 31 float3 Nn = normalize(IN.WorldNormal);
26 float3 Vn = normalize(IN.WorldView); 32 float3 Vn = normalize(IN.WorldView);
27 float3 Hn = normalize(Vn + 33 float3 Hn = normalize(Vn + Ln);
28 // scalar product between light and normal vectors: 34 // scalar product between light and normal vectors:
29 float ldn = dot(Ln,Nn); 35 float ldn = dot(Ln,Nn);
30 // scalar product between halfway and normal vectors: 36 // scalar product between halfway and normal vectors:
31 float hdn = dot(Hn,Nn); 37 float hdn = dot(Hn,Nn);
32 // specialized "lit" function computes weights for 38 // specialized "lit" function computes weights for
33 // diffuse and specular parts: 39 // diffuse and specular parts:
34 float4 litV = lit(ldn,hdn,SpecExpon); 40 float4 litV = lit(ldn,hdn,SpecExpon);
35 float4 diffContrib = 41 OUT.col = litV.x * AmbiColor + litV.y * SurfColor + litV.z * LightColor;
42 return OUT;
36 SurfColor * ( litV.y * LightColor + AmbiColor); 43 float4 diffContrib = SurfColor * ( litV.y * LightColor + AmbiColor);
37 float4 specContrib = litV.y*litV.z * LightColor; 44 float4 specContrib = litV.y*litV.z * LightColor;
38 // sum of diffuse and specular contributions: 45 // sum of diffuse and specular contributions:
39 float4 result = diffContrib + specContrib; 46 float4 result = diffContrib + specContrib;
40 OUT.col = result; 47 OUT.col = result + AmbiColor;
41 return OUT; // output of pixel shader 48 return OUT; // output of pixel shader
42} 49}
43 50

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines