jeudi 7 décembre 2017

Show common part of 2 semitransparent objects?

I'm creating a math app that uses OpenGL to show several geometric 3D shapes. In some cases these shapes intersect and when this happen I want to show the intersecting part of each shape inside the other. As the both shapes are translucent, what I need is more or less something like this:

Perfect intersection

However, with 2 translucent spheres I get that result instead:

With depth testing

I know that, to achieve a correct transparency effect, the depth testing should be turned off before the transparent shapes are drawn. However this cause another side effect when a transparent shape is beyond another non transparent shape:

Without depth testing

So, is there a way to show correctly the intersecting part of 2 volumetric shapes, each inside the other, without breaking the depth testing?

Aucun commentaire:

Enregistrer un commentaire