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.2 |
}; |
8 |
root |
1.1 |
|
9 |
|
|
struct pixelOut { |
10 |
|
|
float4 col : COLOR; |
11 |
|
|
}; |
12 |
root |
1.3 |
|
13 |
root |
1.7 |
pixelOut main(vertexOut IN) |
14 |
root |
1.1 |
{ |
15 |
root |
1.8 |
pixelOut OUT; // output of the pixel shader |
16 |
|
|
|
17 |
root |
1.4 |
float SpecExpon = 120; |
18 |
root |
1.5 |
float4 LightColor = { 1, 1, 1, 1 }; |
19 |
root |
1.3 |
|
20 |
root |
1.8 |
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 |
root |
1.1 |
// specialized "lit" function computes weights for |
29 |
|
|
// diffuse and specular parts: |
30 |
root |
1.8 |
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 |
root |
1.1 |
float4 result = diffContrib + specContrib; |
34 |
root |
1.8 |
|
35 |
root |
1.5 |
OUT.col = result; |
36 |
root |
1.9 |
return OUT; |
37 |
root |
1.1 |
} |
38 |
|
|
|