Sign in to follow this  

Mipmaping a Normal map

This topic is 3314 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 am sure this question must have come up before, but I can't seem to find an answer. Google turns up a lot of incidental suggestions that it can be done, but very little on how. Basically, I have a terrain, represented by a height map. A mesh and a normal map are generated from this height map, and due to the resolution of the height map, I see a lot of aliasing artefacts in the distance. The obvious solution to come to mind was mipmapping, but the results are considerably less than stellar: If you look near the top of the image, you will see odd artefacts with all the hills that slope away from the viewer. Everything looks fine with mipmaps disabled, so the problem appears to be in mipmap generation, for which I am using glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE). Do I need to use a special algorithm to mipmap a normal map, or perhaps a special reconstruction in the fragment shader? In case it is relevant, this is an object-space normal map (not tangent space), and I am re-normalising the normal value in the pixel shader.

Share this post


Link to post
Share on other sites
Turns out that the higher mipmap levels were not even being generated (although for some reason they were considered complete). By switching to glGenerateMipmapEXT(), and making sure to set the MIN and MAG filters beforehand, I seem to have been able to generate the mipmaps (at least no artefacts). I can't seem to see the effect of mipmapping though, despite liberal use of GL_TEXTURE_LOD_BIAS - apparently I am reading the docs wrong.

Edit: and that turned out to be a case of using the wrong function - I needed GL_TEXTURE_MIN_LOD instead. Thanks for bearing with me [smile]

Share this post


Link to post
Share on other sites
Just remember to make sure your mipmapped normal map is properly normalized. I remember once having a problem with my normal map because the lower levels were not normalized. The problems were subtle, but they were there.

Share this post


Link to post
Share on other sites

This topic is 3314 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.

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