blitting tiled textures using openGL

Member
Posts: 39
Joined: 2008.09
Post: #1
have a strange issue. It's a 2d game, and I'm blitting a cycled textures to form a tiled stuff - i.e. a road, like this:
=====, where every '=', is a road tile. It works alright if I render them using integer coordinates, but when I'm using float coordinates, or if I zoom the whole scene, gaps appear, one pixel wide, or less (it's blinking as you move the coordinates, at some position you don't see the gap).
I tried overlapping one sprite over the other, but the black gap was still there, I wonder where it comes from in this case.
What do I do?
Quote this message in a reply
Sage
Posts: 1,234
Joined: 2002.10
Post: #2
Everything in GL is done with subpixel precision internally. I would figure out if the problem is with the vertex positions or the texture coordinates first.

Turn off texturing-- do the gaps still appear? Then your (transformed) vertex positions aren't identical between two tiles. Figure out why.

If the problem goes away when texturing is off, then the problem is probably with your texture coordinates. For example if you have linear filtering turned on, and you're using a texture atlas, the filtering will use the texel just outside of your quad when the vertex position at the edge of the quad ends up on a fractional subpixel. If that's the problem, you need to reconsider what you're trying to do with OpenGL.
Quote this message in a reply
Member
Posts: 39
Joined: 2008.09
Post: #3
Well, in fact it was a GL_CLAMP_TO_EDGE problem, it was solved by using this. However I didn't know that due to some of my ideas I tried to solve this issue, so actually problem was solved and the same issue was introduced by myself, so I didn't know the problem already solved, trying more and more different ideas. Oh dear..
Quote this message in a reply
Sage
Posts: 1,234
Joined: 2002.10
Post: #4
CLAMP_TO_EDGE won't filter the edges of two adjacent tiles correctly, if they are coming from different parts of a texture atlas or from two different textures.
Quote this message in a reply
Member
Posts: 39
Joined: 2008.09
Post: #5
I just quickly tried this and luckily cannot confirm - it did worked with two different textures (I'm not using atlases for this).
However, you guess was quite right somewhere - I do using linear filtering (of course!), and using GL_NEAREST was a solution, too. However results were too ugly and couldn't satisfy me.
Quote this message in a reply
Sage
Posts: 1,234
Joined: 2002.10
Post: #6
If you're happy with your results, great.

But just to illustrate the point, say you have one tile which is all red next to another which is all blue. If you zoom into this, you should see purple filtering between the two tiles.
Quote this message in a reply
Member
Posts: 39
Joined: 2008.09
Post: #7
arekkusu Wrote:say you have one tile which is all red next to another which is all blue. If you zoom into this, you should see purple filtering between the two tiles.

I don't really care while textures look seamless, because that's precisely what I was trying to archive for two days of work.
I don't think there's a better solution anyway. These two tiles would blend into magenta in any case, simply due to the nature of LCD screens. Luckily, you won't be able to see it, because of the high resolution of the display.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL ES Textures Start White demonpants 5 7,124 Sep 3, 2009 06:40 AM
Last Post: Skorche
  opengl es font textures? cool mr croc 0 2,440 Aug 17, 2009 04:52 AM
Last Post: cool mr croc
  OpenGL ES Loading Textures soulstorm 5 6,984 May 25, 2009 07:21 AM
Last Post: soulstorm
  OpenGL textures upside down? orbian 1 9,754 Mar 13, 2009 02:53 PM
Last Post: ThemsAllTook
  OpenGL textures green_ghost 5 3,934 Sep 7, 2008 11:28 PM
Last Post: green_ghost