Jump to content
  • Advertisement
Sign in to follow this  

help wanted regarding normal map

This topic is 3874 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 have an image, that has a black background and normal map of a sphere at the center. This image is wrapped as the texture on a rectangle parallel to x,y axes and lying on z = 0 plane. Now, I'm sending a light position vec4(sin(theta), 0, cos(theta), 1) as a parameter to the shader. This theta is incremented by some delta value in each frame. I mean, I'm sending a point, that moves on the perimeter of the circle x^2 + z^2 = 1. In the pixel shader... 1) I'm converting the 0 to 1 normals into -1 to 1 normalized normals 2) performing a dot product with my light position. 3) and setting the output color as (dotproduct, dotproduct, dotproduct) NOW, the problem I'm facing is... when ever the z value in vec4 becomes negative, the black background is being considered as (-1/root3,-1/root3,-1/root3) normal values and since the light's z < 0, all the pixels for the background are yeilding white pixels. Should I change my code or should I make changes to my normal map? Can someone help me please...

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!