Sprite Flicker

BlitzMax Forums/MiniB3D Module/Sprite Flicker

siread(Posted 2009) [#1]
How can I avoid sprites flickering?



The shadow below the player is a sprite but if I pull the camera out some distance it starts to flicker.


Brucey(Posted 2009) [#2]
It's not a solid colour?


siread(Posted 2009) [#3]
In that shot, no. It's an alpha png. However, I've tried it as a solid colour, masked and so on, but it's always the same.

Actually, this isn't a sprite issue. The same problem occurs to the player models feet if I get rid of the sprite. Time to update drivers...


kfprimm(Posted 2009) [#4]
Add about 0.01 to the Y position of the sprite and player. That should fix it.


siread(Posted 2009) [#5]
Ok, drivers didn't fix it but check this...



The green ground is a cube stretched out flat with a grass texture.

ground = CreateCube()
ScaleMesh(ground, 1000,0,1000)
PositionEntity(ground, 0, 0, 0)

For this example I have made the ground smaller than it should be. The blue behind is nothingness. The tennis court lines are a single sprite placed at 0, 1, 0.

As you can see, where the sprite is floating in space it appears fine but when the ground is beneath it the lines flicker and disappear completely.

This only happens from a high camera viewpoint (in fact it gets progressively worse the higher the camera).



Any ideas?


siread(Posted 2009) [#6]
Add about 0.01 to the Y position of the sprite and player. That should fix it.


I've tried adding as much as 10 to the court sprite but it still occurs when the camera is high.


xlsior(Posted 2009) [#7]
I've tried adding as much as 10 to the court sprite but it still occurs when the camera is high.


Sounds like a rounding issue -- add more when the camera gets higher?


kfprimm(Posted 2009) [#8]
EntityOrder? How about that?


ima747(Posted 2009) [#9]
seconded Khomy's suggestion. I would drop the entity order of the court so it shows behind everything no matter what, that should preserve your depth with the net, players, shadows, etc. properly and force them all to get drawn above the court. also agreeing with xlsior, sounds like a rounding issue with the depth calculation, but the entitiy order should make that a non issue.


simonh(Posted 2009) [#10]
Does this still happen if you use a quad instead of a sprite? I.e. lines=Mesh::CreateQuad()

Also try reducing your camera range ratio - i.e. making the near range bigger or the far range smaller.


Warner(Posted 2009) [#11]
Instead of using 2 objects for the ground, wouldn't it be better to use a single object with 2 layers of texture?


Beaker(Posted 2009) [#12]
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html


siread(Posted 2009) [#13]
Using EntityOrder solves the issue. Will check quads as well.

Instead of using 2 objects for the ground, wouldn't it be better to use a single object with 2 layers of texture?


Yes, that's the plan. Just waiting on the artist for a stadium model. :)