Reputation: 175
In this game im writing I tried to render ice with transparency. Below the ice there is a solid block (a gray one). The light blue planes you can see are the sky sphere you can see through the stone. As you can also see it only doesn't work in one direction. My question is why those planes appear. I'm not drawing any qauds there. The only ones im drawing (the ice blocks) are the ones that face to the air. and the stone below.
I check if a face is drawn like this: check if neighbour cube is transparent AND NOT the same one as the cube which face should be drawn itself
the last check is to prevent that the ice cubes see each other as air and draw all faces where something is transparent.
I read something about transparency order on the internet but I dont't understand exactly what's the problem here.
Upvotes: 0
Views: 184
Reputation: 175
If you are using transparency you have to take care about the order of drawing objects. If you don't care about the order, following might happen:
You can avoid that on object base by sorting objects. First draw solid objects from front to back. After that draw the transparent ones. However, if you have transparent objects near each other or stacked upon each others, you need a more sophisticated algorithm (e.g. order independent transparency) to avoid artifacts.
Upvotes: 2