PDA

View Full Version : Textured quad flickers at edges.



rnodal
06-09-2008, 05:52 PM
Hello:

I was really trying to avoid getting to this point because I thought I was going to be able to solve the issue by myself but I did not. Pretty much the problem is that the edges of the textured quad flicker. Even when rendering 5000 images at around 45fps it is noticeable even thought a little bit less. I have changed the color of the background. Made sure that depth testing is off. Turned on vsync. I really don't have a clue why is happening. The only big difference in code is that I went from calling glBegin/glEnd/glColor4f etc for each image to vertex, color and texture arrays.

Is there anything that I should look for(novice mistake) that may be causing this? Any help would be really appreciated. Thanks for your time.

-r

-NiCo-
06-10-2008, 02:26 AM
Do you mean the flickering didn't appear when implementing it with the glBegin/glEnd/glColor4f calls? That's strange, 'cause when implemented correctly, the array-approach can do the exact same thing.

PS. Did you try out different texture wrap modes?

rnodal
06-10-2008, 12:42 PM
I know it is a weird issue. I tried different texture wrap modes but it did not help the only thing that made a difference was changing:


glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);


to



glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);


Thanks!

-NiCo-
06-10-2008, 12:57 PM
Well, I'm actually still confused about what you mean by flickering. Can you post some screenshots?

rnodal
06-10-2008, 04:32 PM
I think I may have found the source of the problem. I just read from the OpenGL faq that in order to archive "transparency" you need to render your primitives from back to front and use the blend function. I'm doing that and one major difference between my code when things worked and now is that I am rendering things kind of out order. Pretty much what I am doing right now is the following:

Lets say the game is using two textures one for the background and one for objects. Well I'm creating batches of images to render. I render a bunch of images that use texture #1 and then render all the things that use texture#2. That way I only call glBindTexture as little as possible. The problem (I think) is that if I sent the objects first but place them (greater z value) in front of the background when the whole scene renders the objects don't really blend well. Is this reasoning correct. I have depth testing off btw. How can I sort the images so I can render them in batches based on the texture used and still archive blending?

If this does not explain what the problem may be then I will post some screen shots (I need to find a place where to put them).

Thanks.

T101
06-11-2008, 05:26 AM
As long as all your textures need to be rendered with transparency and need to be "correct", they all need to modify what's already in the framebuffer using blending, which means rendering back to front.

If I'm not mistaken the only blend mode where the sort order does not matter is additive blending - but the problem with that is oversaturating the framebuffer.

You might be able to batch a couple of textures together by using multitexturing and texture combiners. Without texture combiners you would have to supply special texture coordinates to point to a white spot on each of those textures, which is tricky. With texture combiners I believe it would be a bit easier, but it's still limited to a few textures per batch.

Another similar technique is to bake multiple textures together into a bigger one. That way you use texture coordinates to select the correct texture. Of course you cannot tile your transparent textures that way.

rnodal
06-12-2008, 11:29 AM
Thanks a lot for your help. You help was great. Thanks!

-r