ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/fsh.cg
Revision: 1.15
Committed: Wed Oct 6 09:41:48 2004 UTC (19 years, 8 months ago) by root
Branch: MAIN
Changes since 1.14: +4 -2 lines
Log Message:
Texture mapping

File Contents

# User Rev Content
1 root 1.2 struct vertexOut {
2 root 1.8 float4 HPosition : POSITION;
3     float4 TexCoord : TEXCOORD0;
4     float3 LightVec : TEXCOORD1;
5     float3 EyeVec : TEXCOORD2;
6     float3 WorldNormal : TEXCOORD3;
7 root 1.12 float3 WorldView : TEXCOORD4;
8 root 1.2 };
9 root 1.1
10     struct pixelOut {
11     float4 col : COLOR;
12     };
13 root 1.3
14 root 1.15 pixelOut main(vertexOut IN, uniform sampler2D Texture)
15 root 1.1 {
16 root 1.12 pixelOut OUT;
17 root 1.8
18 root 1.12 half SpecExpon = 200;
19 root 1.14 float4 AmbiColor = { 0.5, 0.5, 0.5, 1.0 };
20 root 1.5 float4 LightColor = { 1, 1, 1, 1 };
21 root 1.15 float4 diffuse_color = tex2D (Texture, IN.TexCoord.xy);
22 root 1.3
23 root 1.12 half3 Ln = normalize (IN.LightVec);
24     half3 Nn = normalize (IN.WorldNormal);
25     half3 Vn = normalize (IN.WorldView);
26    
27     half3 Hn = normalize (Ln + Vn);
28     half ldn = dot (Ln, Nn);
29     half hdn = dot (Hn, Nn);
30 root 1.8
31 root 1.12 half4 litV = lit (ldn, hdn, SpecExpon);
32 root 1.13 //half4 diffContrib = glstate.material.diffuse * (litV.y * LightColor + glstate.lightmodel.ambient);
33     //half4 specContrib = litV.y * litV.z * LightColor;
34     //half4 result = diffContrib + specContrib;
35 root 1.15 half4 result = diffuse_color * litV.y + LightColor * litV.z;
36     // half4 result = AmbiColor + glstate.material.diffuse * litV.y + LightColor * litV.z;
37 root 1.8
38 root 1.5 OUT.col = result;
39 root 1.9 return OUT;
40 root 1.1 }
41