Jump to content
  • Advertisement
Sign in to follow this  
peter.lapisu

OpenGL OpenGL gridtile mapping artefacts

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

hello

if you look at the attached picture, you will understand the problem

- turned off mip-mapping doesnt help (makes it better, by viewing from distance, but doesnt fix it)
- GL_CLAMP_TO_EDGE is used

it also shows up in blender

how can this problem be solved

Share this post


Link to post
Share on other sites
Advertisement
If I had to guess, your vertices for adjacent quads aren't being computed the exact same way, so due to rounding errors you're left with cracks between the tiles.

How are you calculating your vertex positions?

Share this post


Link to post
Share on other sites
Are you using tilemaps (multiple tiles per image)? If so then clamp_to_edge won't really save you from hitting neighboring tiles.

Share this post


Link to post
Share on other sites
yes, we use tilemaps

this image demonstrates the problem
http://www-sop.inria.fr/reves/Basilic/2008/Lef08/a.fig.png

we would like to get the results on right

Share this post


Link to post
Share on other sites
Notice that a texture atlas is a kind of "misuse" of a single texture as it were several textures. However, since it is still only a single one, OpenGL can apply CLAMP_TO_EDGE just at the real edges of the texture but not at the edges of the tile areas inside the texture. So you have to fake such a behavior.

E.g. a fragment script can investigate the (u,v) co-ordinates and perform a clamp to tile borders (assuming that the tiles are so neatly arranged as can be seen in one of the screen shots).

Or you create textures that are slightly bigger than those so far, where each tile gets a explicit texel borders. (But this is usually unsatisfactory, because it means to either drop POT sizes or to waste much texture memory.)

Or you fake the borders above by using the existing outermost texels of each tile as borders, i.e. use sightly inset (u,v) co-ordinates. This is perhaps the best compromise if you don't want to write your own shader scripts.

Or ... well, I have no other idea yet :(

Notice that you have another option if you want pixel perfect mapping, e.g. in a pure orthogonal top-down or side projection where the quads are screen aligned. In such a case you can guarantee that the (u,v) co-ordinates at the tile borders will hit texel centers exactly and hence interpolation will not pollute the colors.

Share this post


Link to post
Share on other sites
The last time I had to deal with that kind of thing I ended up using the magical texture coordinate offset value and making sure that scaling would always happen in a way that leaves vertices on full pixels. Not to mention I said bye to linear filtering. This time around I just use texture arrays, even though it seems to be a relatively new feature and limits the audience. By having each image on a separate slice of a 3D texture you can filter and texture wrap all you like. You should be able to get the same effect with a regular 3D texture and keeping the third texture coordinate right on a slice. Both methods would be a bad choice if your tiles aren't all the same size.

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!