Jump to content
  • Advertisement
Sign in to follow this  
newObjekt

Texture filtering on normal and specular maps

This topic is 1866 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

Hey, I have a quick question about my normal and specular maps causing really bad texture artifacts at a distance.

Here's some pictures of the problem. (ignore the weird blue lights, was messing with glow lights in my shader)

 

http://inferno.codebrainshideout.net/Images/hangemhigh%201.png

http://inferno.codebrainshideout.net/Images/hangemhigh%202.png

 

Should I look into anti aliasing or anistropic filtering? Or do I need to filter the maps in my glsl shader?


Here is my GLSL fragment shader as well, it's a mess right now, I know :P

http://inferno.codebrainshideout.net/modelShader.frag

Relevant code is inside of the if(useNormal) { }

 

Thanks : )

Edited by newObjekt

Share this post


Link to post
Share on other sites
Advertisement

For starters, it looks like you are just simply using bilinear filtering for those texture maps.  Before you can use anisotropic filtering, you got to have trilinear filtering enabled (which is mipmapping).  Are you creating mipmaps for your normal and specular maps?  Do that first, then use anisotropic filtering.  Antialiasing isn't going to help with this.

 

I wrote an example on how to use anisotropic filtering, but that HDD crapped out and I might have lost it for good =(

 

Shogun.

Share this post


Link to post
Share on other sites

You should definitely mipmap, use trilinear filtering, but in addition to that you should renormalize the normal map lookup result before putting it into your lighting calculation.

Share this post


Link to post
Share on other sites
Yeah it looks simply like you're not using mipmapping, so when the texture is shrunk by more than 2x, bilinear filtering (which blends 4 texels) won't be able to stop it from shimmering.

Share this post


Link to post
Share on other sites

Alright I've got mipmap generation and Anistrophic filtering working and it's given very nice results.

 

http://inferno.codebrainshideout.net/Images/mipmaps%20a.png

 

Though I've noticed an odd issue. At extreme angles textures seem to turn completely black. I think this might be a specular problem? I'm not sure.

 

http://inferno.codebrainshideout.net/Images/mipmaps%20b.png - Wall at a normal angle.

http://inferno.codebrainshideout.net/Images/mipmaps%20c.png - Wall at a extreme angle.

 

Additionally I don't know what mhagain meant by "renormalize" the normal maps. Is that the same as calculating the tangent and binormal and applying those to the normal map?

 

-edit-

It's not a specular problem. It's a problem the tangent and binormals I think. I disabled normal maps but left specular maps enabled and the black faces effect was gone. But I noticed that the specularity was completely gone at the angles that caused the black faces.

Edited by newObjekt

Share this post


Link to post
Share on other sites

"Renormalize" means you take the new value and normalize it (i.e. give it a length of 1). Essentially:

distance = sqrt(x*x + y*y + z*z);
x /= distance;
y /= distance;
z /= distance; 

Well, you get the idea. Or you could just call normalize on the value within the pixel shader and let it do the job for you (though it burns up some more cycles in the GPU code).

Share this post


Link to post
Share on other sites

I note from your fragment shader code that you're already doing this, so nothing to worry about here.

 

vec3 tnormal = 2.0 * getTex(1, gl_TexCoord[0].st).rgb - 1.0;
tnormal = normalize (tnormal);

Share this post


Link to post
Share on other sites

I ended up solving my own problem with the "triangles turning completely black" problem. I had sunLocation set as a vec4 but was accidentally doing glUniform3f to send the coords to GLSL. Changed it and it fixed the problem.

 

Thanks for the help. :)

Edited by newObjekt

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!