Sign in to follow this  
TheFallenOne

Mipmaps and Texture Seams

Recommended Posts

TheFallenOne    136

Hey guys,

 

I'm having a bit of an issue with texture mipmaps.

 

I have a model that uses a diffuse texture that doesn't stretch to the edge of the image file. To clarify, the edges of the texture are padded with a solid black color, and the texture coordinates on the model never hit either 0 or 1, they use a smaller subset of the texture.

 

When I disable mipmaps, everything works great, but with mipmaps, the edge of the texture is showing a line from the black pixels bordering the texture, making it appear like the model has a seam in it.

 

My guess is either the mipmaps are sampling part of the black pixels, or the texture coordinates are coming out with a different result on the mipmap'd texture.

 

Does anyone have any suggestions on how to fix this?

 

I can post images and code if needed.

Share this post


Link to post
Share on other sites
Hodgman    51234

How are you generating your mipmaps, and/or what do they look like?

 

The default way of generating each mipmap level is to simply down-sample the level above by 50%. Four original pixels are averaged to get the new mip pixel. At the edge of a shape, you'll be blending some 1/2/3 of that shape's pixels with 3/2/1 black pixels, causing the blackness to 'bleed' into your shape.

 

You can either take care when generating the mipmaps, so that these black pixels are ignored, or, you can replace the black textures with similar colours to the nearby shapes so that the automatic/default algorithm doesn't do as bad of a job.

Share this post


Link to post
Share on other sites
mhagain    13430

This sounds like you're padding textures to work around non-power-of-two restrictions.  The first thing you should definitely do is check for non-power-of-two support and if you've got it, then don't bother with the padding.  Otherwise, instead of padding to black, you can repeat the last row/column to the full padded extent of the texture.

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