View Full Version : Texture Flickering on the Right Side of the Screen

02-08-2011, 06:51 AM
I have Sprites in the Size of 64x64. They enter the screen from the right.
Their initial position is:
So they don't spawn in front of the player.
When they enter the screen on the right, I get a texture flickering. I have made a screenshot to explain things:
The red line from top to bottom shows where the Flickering is. It is on the right side of this line. The red quad on the sprite shows which part of the texture is flickering. I hope that describes my issue well enough.

The sprites are png texture with transparency. I do an alpha test inside a shader to render them.

if ( col.a >= 0.1f )

The Background consists of 2 Layers which are scrolled along their x-texture-coords inside another shader.

The textures are generated either with GL_CLAMP_TO_EDGE or GL_REPEAT, depending on the usage of the texture. Currently, only the backgroun images are generated with GL_REPEAT.
All sprites use different z-values, in 0.1f steps to avoid z-fighting.
Orthographic view has a z-near of -1.0f and a z-far of 1.0f.

I hope that covers all informations. If you need more let me know please. Thanks.

02-08-2011, 07:42 AM
Do you know the Shannon/Nyquist sampling theorem ?
http://en.wikipedia.org/wiki/Nyquist%E2%...nals_and_images (http://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem#Applicati on_to_multivariable_signals_and_images)

You have 2 ways of solving it :
- make everything pixel exact : GL_NEAREST sampling, positions in whole pixel integer increments
OR :
- prefilter your texture data so that the changes in texture are not so sudden (so the 'frequency' of color changes is low enough for per pixel sampling) -> it means blur a bit your images. 1-pixel wide gaussian should be enough, try different values.

EDIT : I see there is a suspicious white line all around your sprite, which probably exagerate the problem. GL_NEAREST will avoid the white to bleed around, if it has alpha=0.

02-08-2011, 07:58 AM
Hi ZBuffeR.
Thanks for your reply. I feel kinda dumb not to thought about GL_NEAREST. That solved the problem entirely and also the white line around my sprites.
Thanks a Ton.