Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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);
And in PixelShader:
//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 this post

Link to post
Share on other sites
Original post by martinperry
Output.halfway = normalize(mul((wEye + wLight), tanMat)); ...
What you are doing there is incorrect. It should instead read:
Output.halfway = mul(normalize(wEye + wLight), tanMat);

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

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!