• Advertisement
Sign in to follow this  

Global Normal Maps

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

I have been using 3D Studio Max to bake some normal maps and there is an option in max to bake them into world coordinates. Well I tried that, but now I'm having problems writing my GLSL frag and vert files. For some reason I can't seem to get the light_direction variable right. Other than that, I can just read in the normal information straight from the texture map and have the normals instantly. I'm wondering what the easiest way to get the exact vector from the light to a certain fragment so that I can dot that vector with my normal information and do the mapping that way. If not, is there any good way to use a world coordinate normal map? I also realize that they will only work for static objects but that's not a problem.

Share this post


Link to post
Share on other sites
Advertisement
Maybe I'm not making myself very clear. Here's a pic of the texture map I'm using and then a pic of what the object looks like when it's rendered using the normal map as a diffuse map in the application.

http://filebox.vt.edu/users/rengle/stuff/normmap.jpg

http://filebox.vt.edu/users/rengle/stuff/normsphere.jpg

Share this post


Link to post
Share on other sites
Pass the world space position of the light to the vertex shader. Use that to calculate the light vector at each vertex. Pass that to the fragment shader (as a texture co-ord). Each fragment will then get an interpolated light vector from the 3 verts that make up it's triangle. Because it's interpolated it'll probably not be unit length so you should normalise it using either a normalisation cube map or fragment shader arithmetic. You can then dot the light vector with your normal from the normal map and you have your lighting value.

Share this post


Link to post
Share on other sites
Quote:
Original post by MARS_999
Links are broken


That's weird. What does it say? They seem to be working for me.

Share this post


Link to post
Share on other sites
When I send it the light value it seems to work a bit better. But when I rotate around the sphere that is normal mapped, with my point light attached to the camera, it seems to make the light on the sphere rotate like a plane spinning instead of rotating with me, which makes me think somehow something is reversed. Any ideas?

Share this post


Link to post
Share on other sites
Problem solved. My coordinates were mixed up since 3D Studio Max and OpenGL have different y and z axis. Thanks.

Share this post


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

  • Advertisement