Jump to content
  • Advertisement
Sign in to follow this  
martinperry

Directional light and Specular problem

This topic is 3080 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
Advertisement
Quote:
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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!