Tile Bleeding with GL_NEAREST

rzilibowitz
Unregistered
 
Post: #1
I've noticed a few posts about tiling or tile based games in opengl, so forgive me if this question has already been dealt with... but I'm not sure if it has...

I am confounded by a problem with rendering 2d tiles under a glOrtho matrix. I am using GL_NEAREST so filtering should not be an issue.

When scrolled to some positions everything looks ok. But scrolled to another position the tiles get adjacent texels bleeding into them. I have all my tiles on a single texture and use fractional texture coords.

These two screenshots should make my problem fairly clear:

users.bigpond.net.au/rz/right.tiff
users.bigpond.net.au/rz/left.tiff

I have come across the article about the gluOrtho2D bug in OpenGL. Is this an example of the bug that I'm experiencing? And is this a bug in the OS X implementation of OpenGL or is it on all systems?
Quote this message in a reply
Sixten
Unregistered
 
Post: #2
Is each of those tiles a separate quad, drawn side by side in the same plane? If so, then maybe you're seeing the problem described in the red book here (search for Figure 2-13).

Unfortunately, I'm not really sure the best way to solve this problem is in the tile scenario. You can't really make the joins non-orthogonal, like the book suggests.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #3
Use integer coordinates instead, it'll give you much better results in tiled games. (and less headache) That way you won't get that "swimming tiles" look either.
Quote this message in a reply
rzilibowitz
Unregistered
 
Post: #4
Yeah, if I convert my values for gluOrtho2D to integers it does solve the problem... almost.

I still have a strange problem of vertical flickering as it scrolls. - looks a bit like a tv with bad reception or something. That might sound wierd, but thats what it does.

I do have double buffering on and I checked with SDL_GL_GetAttribute. And it seems to be only vertical flicker regardless of whether I draw my tilemap rows first or columns first. It flickers with light and dark bands. Any ideas what could be causing this?
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #5
rzilibowitz Wrote:I still have a strange problem of vertical flickering as it scrolls. - looks a bit like a tv with bad reception or something. That might sound wierd, but thats what it does.
do you have VBL syncing turned on? it's really simple to turn on in most applications
Quote this message in a reply
Moderator
Posts: 608
Joined: 2002.04
Post: #6
[sourcecode]
const long synch = 1;
CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &synch);
[/sourcecode]Call that after all your SDL setup code to turn on VBL synch. You will have to include OpenGL/OpenGL.h in order to get the CGL functions.
Quote this message in a reply
rzilibowitz
Unregistered
 
Post: #7
ok, thanks... this is really interesting. That stops the flickering from involving bands across the screen. It looks much better. But now it is a whole window flicker. It flickers noticeably between light and dark when scrolling. As soon as scrolling stops it settles on light which is how it should look. So the flickering problem hasn't gone away. Any ideas?
Quote this message in a reply
Moderator
Posts: 916
Joined: 2002.10
Post: #8
do you have an LCD by chance?
Quote this message in a reply
rzilibowitz
Unregistered
 
Post: #9
yes, I do... an ibook... what would that mean ?
Quote this message in a reply
rzilibowitz
Unregistered
 
Post: #10
well, I tried my code on my iMac and sure enough it looked perfect on a CRT display. So the flickering was because of the lcd. Why on earth does this happen?
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Post: #11
rzilibowitz Wrote:well, I tried my code on my iMac and sure enough it looked perfect on a CRT display. So the flickering was because of the lcd. Why on earth does this happen?

It takes the lcd pixels a while to go from light to dark. So depending on your tile graphics, you might be "smearing" them a bit because of the lcd's speed.
Quote this message in a reply
rzilibowitz
Unregistered
 
Post: #12
wow, that's really interesting. makes sense. never wouldn't thought of that probably. thanks
Quote this message in a reply
Post Reply