Sign in to follow this  
Saughmraat

help wanted regarding normal map

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this