# Directional light and Specular problem

This topic is 3171 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, i am not really sure what i have wrong in my code, but result with directiona light looks like this There is very good to see, that in one point is wall lightened with point light. I am calculating light in Vertex Shader:
float3 wLight = xLightDirection; //light direction
float3 scaledPos = mul(float4(PSIn.pos, 1), wordlMatrix).xyz
float3 wEye = xEyePos - scaledPos; //xEyePos - position of camera; scaledPos - player position

...
Output.light = normalize(mul(wLight, tanMat));
Output.halfway = normalize(mul((wEye + wLight), tanMat)); //tanMat is tangentMatrix

Output.Position = mul(float4(scaledPos, 1), xViewProjection);

//n = normal value from bump map or from normal directly from VS
n = (n - 0.5f) * 2.0f;
n = normalize(n);
float3 h = normalize(Input.halfway);
float nDoth = saturate(dot(n, h));
float power = (nDotL == 0.0f) ? 0.0f : pow(nDoth, 100);

Anyone see something wrong ?

##### Share on other sites
Quote:
 Original post by martinperry...Output.halfway = normalize(mul((wEye + wLight), tanMat)); ...
Output.halfway = mul(normalize(wEye + wLight), tanMat);

Not sure if that is "the" problem, but it is definitely "a" problem.

##### Share on other sites
That was "a" problem, but not "that" problem.... so light is still incorrect

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633769
• Total Posts
3013758
×