Line | |
---|
1 | struct ShadedTex_OUT
|
---|
2 | {
|
---|
3 | float4 vPos : POSITION;
|
---|
4 | float4 texCoord : TEXCOORD0;
|
---|
5 | float4 wNormal : TEXCOORD1;
|
---|
6 | float4 wPos : TEXCOORD2;
|
---|
7 | };
|
---|
8 | #define SAMPLECUTDIST2 0.01
|
---|
9 | float4 TexturedShadedOneLight_PS(ShadedTex_OUT IN,
|
---|
10 | uniform float3 lightPos,
|
---|
11 | uniform float3 lightDir,
|
---|
12 | uniform float3 lightColor,
|
---|
13 | uniform float lightPower,
|
---|
14 | uniform sampler2D colorTex : register(s0)):COLOR0
|
---|
15 | {
|
---|
16 | float4 color = 1;
|
---|
17 |
|
---|
18 | lightDir = normalize(lightDir);
|
---|
19 | IN.wNormal.xyz = normalize(IN.wNormal.xyz);
|
---|
20 |
|
---|
21 | float3 diff = lightPos - IN.wPos;
|
---|
22 | float dist2 = dot(diff, diff);
|
---|
23 | if(dist2 < SAMPLECUTDIST2)
|
---|
24 | dist2 = SAMPLECUTDIST2;
|
---|
25 | diff = normalize(diff);
|
---|
26 | float cosa = max(dot(lightDir, -diff), 0);
|
---|
27 | float cosb = max(dot(IN.wNormal.xyz, diff), 0);
|
---|
28 |
|
---|
29 | color.rgb = pow(cosa, 9) * cosb / dist2 * lightPower;
|
---|
30 | //color.rgb *= lightPower;
|
---|
31 | //return 0;
|
---|
32 | return color * tex2D(colorTex, IN.texCoord);
|
---|
33 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.