Sprites And EntityAlpha Problem

Blitz3D Forums/Blitz3D Programming/Sprites And EntityAlpha Problem

Red Ocktober(Posted 2003) [#1]
I've got a lil problem, one which I'm sure someone has run up upon before...

I am having a problem with a Spite (particle) that is in front of a mesh entity that is translucent (EntityAplha .88)

It seems that sometimess the Sprite gets painted over by the translucent entity, and a small percentage of the time it does not.

These screenshots should show exactly what I am trying to say..

[img ]
vapor (smoke) gets partially overpainted by water (the translucent mesh that is deformed)

[img ]
when the water alpha is changed to 1 (no transparency) everything looks fine...

Thanks in advance for any help, or ideas with this...

--Mike


Ken Lynch(Posted 2003) [#2]
This has been talked about a lot. I posted it as a bug once and it got a bit heated with someone else saying 'No it's not a bug' but without explaining it. After quite a few months there was finally an explanation, so here goes...

Alpha blended objects are all rendered after solid objects and don't set the Z buffer (for speed) and because 3D graphics cards don't bother sorting polygons (this does't matter for solid objects) you sometimes get objects draw in the 'wrong' order, this is especially noticable when you have large transparent objects like your sea.

So it's basically a limitation in the technology we currently have on 3D graphics cards and the only way round it is to be careful with transparent objects.


Red Ocktober(Posted 2003) [#3]
Thanks Ken for the info...

... this is really frustrating.

My only solution so far is to make the water none translucent...

--Mike


jhocking(Posted 2003) [#4]
That is a completely correct explanation of why it is happening but your vague "be careful with transparent objects" advice isn't too helpful. To finish his explanation, the draw order of alpha blended polygons is determined by entity position. Unfortunately, since an entity's position is a single point the polygons are inevitably offset from the position (and for large objects like your sea the polygons are offset a LOT.) Because of this offset the polygons aren't always drawn in the correct order. The polygons of your sea are further away than those of the smoke, but since the entity position of the sea is closer the sea is drawn over the smoke.

To get around this you will have to find a way to break up your water into multiple objects. Thus the entity position of the distant water will be a truer approximation of the polygon positions.

Or make the water opaque. This is less than ideal but then in your screenshot the water doesn't look very transparent anyway. Plus there is some realistic basis for this; water actually looks pretty opaque at an oblique angle (such as the viewpoint in those screenshots) due to reflection. Water only really looks transparent when you are looking at it straight down.