Welcome! Log In Create A New Profile


[GX] Drawing problems

Posted by copete23 
[GX] Drawing problems
November 07, 2009 09:21PM
Hi, I'm having some problems when using textures with transparency, the model looks good, transparent, but if I load another object then this happens:

Does anyone know what I'm doing wrong?

Thanks ! :)
Re: [GX] Drawing problems
November 07, 2009 11:37PM
Yes, you have to draw the objects in a different order: Transparent or translucent objects near the camera must be drawn the last.
Re: [GX] Drawing problems
November 08, 2009 01:39AM
ok, but for example in this case the two objects are transparent and are drawn at the end, like this:







If i have a lot of transparent objects, it is the same between them.
Re: [GX] Drawing problems
November 08, 2009 08:08PM
An object only gets drawn into a pixel if the previous drawn pixel is further from camera than he is. For example if you drawn the floor after the transparent object, you would see two holes in the floor where the objects are.
To face that problem, what I do in revolution engine is:
-First draw alwais solid, non translucent objects.
-Second, create an ordered list with containing all translucent objects, order based on the distance to the camera. This orderr must be recalculated every frame if the objects or the camera are moving.
-Third, draw translucent objects from back to front.
Re: [GX] Drawing problems
November 08, 2009 08:39PM
ok, I see, i´ll try whith that.

thanks technic
Re: [GX] Drawing problems
November 11, 2009 03:42PM
Note, you get this because of the ZBuffer/DepthTesting.

One of the ways around it is sorting your draw order (as explained by technik). But there are other ways.

You can disable the DepthTesting:

I use this function:
void setZBuffer(int enable)
if (enable)

To enable/disable depth testing. This will also draw stuff even while behind other objects, so it might not be what you want, but it's faster then sorting everything.

Another way would be alpha testing, which produces even different results. But I don't know how to enable that in GX.
Re: [GX] Drawing problems
November 11, 2009 06:34PM
Actually, disabling depth testing is a widely used technique, but it's also physically wrong. when multiple translucent surfaces overlap, the order matters. Looking at a blue glass through a green one is different that the opposite.

C1*a1 + (1-a1)*(C2*a2+(1-a2)C3) is not the same as C2*a2 + (1-a2)*(C1*a1+(1-a1)C3).

So the first method will give a more realistic result. Difference, however, is small, so you have to weight wether you prefer a faster algorithm or a more preciese one.
Sorry, only registered users may post in this forum.

Click here to login