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

Comparing libgender/fsh.cg (file contents):
Revision 1.6 by root, Tue Oct 5 08:14:21 2004 UTC vs.
Revision 1.21 by root, Mon Oct 18 14:31:36 2004 UTC

1// final pixel output:
2// data from pixel shader to frame buffer
3struct vertexOut { 1struct vertexOut {
4 float4 HPosition : POSITION; 2 float4 HPosition : POSITION;
5 float4 TexCoord : TEXCOORD0; 3 float4 TexCoord : TEXCOORD0;
6 float3 LightVec : TEXCOORD1; 4 float3 LightVec : TEXCOORD1;
5 float3 EyeVec : TEXCOORD2;
7 float3 WorldNormal : TEXCOORD2; 6 float3 WorldNormal : TEXCOORD3;
8 float3 WorldPos : TEXCOORD3;
9 float3 WorldView : TEXCOORD4; 7 float3 WorldView : TEXCOORD4;
8 float3 test1 : TEXCOORD5;
9 float3 test2 : TEXCOORD6;
10}; 10};
11 11
12struct pixelOut { 12struct pixelOut {
13 float4 col : COLOR; 13 float4 col : COLOR;
14}; 14};
15 15
16// pixel shader 16pixelOut main(vertexOut IN, uniform sampler2D Texture)
17pixelOut main(vertexOut IN // input from vertex shade
18 //uniform float SpecExpon, // constant parameters fro
19 //uniform float4 AmbiColor, // application
20 //uniform float4 SurfColor,
21 //uniform float4 LightColor
22 )
23{ 17{
18 pixelOut OUT;
19
24 float SpecExpon = 120; 20 half SpecExpon = 200;
25 float4 LightColor = { 1, 1, 1, 1 }; 21 float4 LightColor = { 1, 1, 1, 1 };
22 float4 diffuse_color = tex2D (Texture, IN.TexCoord.xy);
26 23
27 pixelOut OUT; // output of the pixel shader
28 float3 Ln = normalize(IN.LightVec); 24 half3 Ln = normalize (IN.LightVec);
29 float3 Nn = normalize(IN.WorldNormal); 25 half3 Nn = normalize (IN.WorldNormal);
30 float3 Vn = normalize(IN.WorldView); 26 half3 Vn = normalize (IN.WorldView);
31 float3 Hn = normalize(Vn + Ln); 27
32 // scalar product between light and normal vectors: 28 half3 Hn = normalize (Ln + Vn);
33 float ldn = abs(dot(Ln,Nn)); 29 half ldn = dot (Ln, Nn);
34 // scalar product between halfway and normal vectors:
35 float hdn = abs(dot(Hn,Nn)); 30 half hdn = dot (Hn, Nn);
36 // specialized "lit" function computes weights for 31
37 // diffuse and specular parts:
38 float4 litV = lit(ldn,hdn,SpecExpon); 32 half4 litV = lit (ldn, hdn, SpecExpon);
39 float4 diffContrib = glstate.material.diffuse * ( litV.y * LightColor + glstate.lightmodel.ambient); 33 half4 diffContrib = diffuse_color * ((litV.y + 0.3) * LightColor + glstate.lightmodel.ambient);
40 float4 specContrib = litV.y*litV.z * LightColor; 34 half4 specContrib = litV.y * litV.z * LightColor;
41 // sum of diffuse and specular contributions:
42 float4 result = diffContrib + specContrib; 35 half4 result = diffContrib + specContrib;
36 //half4 result = diffuse_color * litV.y + LightColor * litV.z;
37
43 OUT.col = result; 38 OUT.col = result;
44 return OUT; // output of pixel shader 39 return OUT;
45} 40}
46 41

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines