Jump to content
  • Advertisement
Sign in to follow this  
realh

Texture atlas edge sampling errors with filtered scaling or mipmaps

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

Is it best to avoid mip-mapping for texture atlases? When using a texture atlas you can get glitches where the texel on a rendered surface is at the edge or corner of its region in the atlas, because the sampling can spill over to adjacent regions.

 

One way to avoid this is to add half a pixel's worth to the UV coordinates on the left/bottom of a region and subtract half a pixel from the top/right. The trouble is that could cause slight distortion of the texture if using a blending filter, and it would stop being effective with mip-mapping.

 

Another way to avoid it is to add margins around each region, duplicating the edge and corner pixels. This would prevent the above distortion problem, but it's still difficult to deal with mip-mapping. You'd have to make each margin quite wide to make it look right for a reasonable number of mipmap levels, probably doubling the width and height of the atlas; and you'd have to generate each mip-map manually or in code instead of automatically, to get the corners right.

 

It might be possible to write a custom shader that does the equivalent of the first strategy but only on the fragments that need it, thus avoiding potential distortion, but it could be very difficult to work out which mip-map level it should adjust for at any given fragment. And one might not want the extra hassle of writing such a shader when using an off-the-shelf engine.

 

 

Share this post


Link to post
Share on other sites
Advertisement

Have you read Ysaneya's blog post on the issue from a while back?

I hadn't seen that. Interesting article, shame about the missing pics. The trouble is, it relies not only on a custom shader, but one that's more complicated than I feared and won't work on many OpenGL ES 2.0 devices.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!