Sign in to follow this  

tile edges visible (texture coordinate precision and interpolation issue)

This topic is 4173 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 textures that contain 8x8 non-adjacent tiles (essentially randomly placed in the textures; which means that they don't generally blend at edges). I'm mapping these onto a terrain using fractional texture coordinates, such as: first texture tile: (0, 0) -> (1 / 8, 1 / 8), etc. The problem I'm having is visible edge artifacts where the tile edges appear. These aren't so much visible close up, but become very apparent at a distance as accuracy decreases. It's fairly obvious that the problem lies in interpolation (proven by the fact that the problem is much worse in trilinear (GL_LINEAR_MIPMAP_LINEAR) than in any GL_NEAREST_* mode). If that is too fuzzy, try to think of a tile that has a texture from a tile map on it. That texture, however, is smaller than the tile and you can see the edges of the adjacent tile textures, forcing a distinct line between the actual tiles. The way I see it, the only foolproof solution would be to split the textures up at loadtime into 64 chunks and load each one as a separate texture. However, that also sounds a bit nutty considering than in more extreme cases I have to load up to 11 to 13 textures, each having 64 tiles (totalling up to 1000 textures, demanding that I bind a new one for each tile). Are there any other solutions? Cheers, i.

Share this post


Link to post
Share on other sites
u could manually create the mipmaps yourself. ie dont use generate_mipmap (it wont solve the prolem completely, 4 that u will need to supply a 1 pixel border around each tile)

Share this post


Link to post
Share on other sites
zedzeek - the problem with bordering the tiles is that the textures I'm loading are from inside a large archive and I don't have access to them to add the border in advance. So I'd have to resize the tiles at loadtime and then use some nasty texture coordinate hack (what Bob III suggested) to exclude the borders.

I was secretly hoping there'd be a way to use scissoring in the texture matrix (eek...) or some other mapping techniques to overcome this problem. For now, however, it seems separating each tile into its own texture seems to be the most viable solution...

Share this post


Link to post
Share on other sites
Hi,

I was having the exact same problem, the edges of my tiles were really visible. I found this code snippet (http://www.idevgames.com/forum/showthread.php?t=1840)

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

I don't exactly know what its doing, but it sure fixed up my tile edge problem, hope it works for you too.

Cheers,

Chrid

Share this post


Link to post
Share on other sites

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