Login  Register

Mixing translucent objects in a GL scene

Posted by Martin on Jan 29, 2012; 6:46pm
URL: https://forum.jogamp.org/Mixing-translucent-objects-in-a-GL-scene-tp3697955.html

Hi folks!

I am seeking to use several translucent and non translutent objects that cross each other in a Jzy3d scene.

Up to now, Jzy3d was using a simple and naive approach to deal with translucent polygons: each shape is a composite made of quads or polygons, and is splitted at rendering, in order to sort all atomic polygons according to the distance of their barycenter to the current camera eye position. The problem is that the barycenter is a to approximated measure when polygons have very different size (see the cylinder nested in a box attached).

Indeed, the nested cylinder image attached shows that the barycenter approach makes the top side of each gray box farest from the barycenter of each cylinder side standing in front of the camera. The latter are thus rendered latter and override the top gray polygon.

The idea of sorting the splitted shapes this way relies on the idea that it seams necessary to init GL the following way to consistantly handle transparency:
1) Activate alpha buffer
2) Desactivate depth buffer

Splitting each side of the box into multiple cells could be an idea, but that would rapidly imply many polygons for a simple paralleliped. Moreover, the visual success would always depend on the resolution of the tesselated face, related to the size of its content (cylinder radius).

Does anybody has a generic method for handling clean transparency?

Thanks in advance for your suggestions.

Martin