1 |
struct vertexOut { |
2 |
float4 HPosition : POSITION; |
3 |
float4 TexCoord : TEXCOORD0; |
4 |
float3 LightVec : TEXCOORD1; |
5 |
float3 EyeVec : TEXCOORD2; |
6 |
float3 WorldNormal : TEXCOORD3; |
7 |
}; |
8 |
|
9 |
struct pixelOut { |
10 |
float4 col : COLOR; |
11 |
}; |
12 |
|
13 |
pixelOut main(vertexOut IN) |
14 |
{ |
15 |
pixelOut OUT; // output of the pixel shader |
16 |
|
17 |
float SpecExpon = 120; |
18 |
float4 LightColor = { 1, 1, 1, 1 }; |
19 |
|
20 |
float3 Ln = IN.LightVec; |
21 |
float3 Nn = IN.WorldNormal; |
22 |
float3 Vn = IN.EyeVec; |
23 |
|
24 |
float3 Hn = 0.5 * (Ln + Vn); |
25 |
float ldn = dot (Ln, Nn); |
26 |
float hdn = dot (Hn, Nn); |
27 |
|
28 |
// specialized "lit" function computes weights for |
29 |
// diffuse and specular parts: |
30 |
float4 litV = lit (ldn, hdn, SpecExpon); |
31 |
float4 diffContrib = glstate.material.diffuse * (litV.y * LightColor + glstate.lightmodel.ambient); |
32 |
float4 specContrib = litV.y * litV.z * LightColor; |
33 |
float4 result = diffContrib + specContrib; |
34 |
|
35 |
OUT.col = result; |
36 |
return OUT; |
37 |
} |
38 |
|