Transparency Hiding Shapes

Hello,

Since this is my first post in a long time I just want to thank all of you guys working on Xith and making it available to the community at large.

My scene consists of one big hollow box with a whole bunch of smaller shapes inside it. My problem is when setting the transparency of the big box, some (not all) of the shapes start dissapearing from the view. And depending on the rotation of the box, some shapes will appear and other will disapear. The image I’m attaching shows the box with its polygon attributes set to POLYGON_LINE, to show you all the shapes that should be appearing in the scene, and 3 other views at other rotations with the transparency set. You’ll notice that some shapes appear and disapear.

What I’d like to do is always have the shapes appear when the big box’s transparency is set. Any ideas where I could be going wrong in my scene setup?

This is part of a pretty big program so providing code samples of the whole rendering process would be difficult, but if you feel a certain piece would help please let me know.

Thanks!

After going at it some more and reading some older threads here I found that adding this to the appearance setup fixes it:


RenderingAttributes ra = new RenderingAttributes();
ra.setDepthBufferEnable(false);
appearance.setRenderingAttributes(ra);

But now when the box shape is set to zero transparency the other shapes are bleeding through and showing :frowning:

Help! :slight_smile:

Here’s my appearance init for the box shape:


    appearance.setPolygonAttributes(new PolygonAttributes(polygonFill,
            PolygonAttributes.CULL_NONE, 0));
    appearance.setColoringAttributes(
            new ColoringAttributes(color, ColoringAttributes.NICEST));
    appearance.setTransparencyAttributes(new TransparencyAttributes(
	    TransparencyAttributes.BLENDED, opacity));

   RenderingAttributes ra = new RenderingAttributes();
   ra.setDepthBufferEnable(false);
   appearance.setRenderingAttributes(ra);

Hi,

This directly relates to transparency sorting policy set in Xith3D View. By default, rendering order is determined by sorting distances from the shape center (center of bounding sphere) and eyepoint (which in your case is not correct because of your box ENCLOSES all the shapes, and this explains situation with rotations). Better option is TRANSPARENCY_SORT_BOUNDING_SPHERE_AND_EYE_RAY_INTERSECTION transparency sorting policy, but to achieve better results you should break your box to six planes, so they treated as separate objects.

Currently, there is no easy solution for multiple-intersecting AND, MOST IMPORTANT, SELF-INTERSECTING shapes. There is a technique called multipass depth peeling, but it requires high-end GPU hardware.

Alternatively, you may employ some of your application specifics and constraints by placing your shape in the ordered group and directly manipulating their rendering order (by defining order index mapping). In this case you can (and should) switch transparency sorting off on scene-basis or on shape-bases (see setSortEnabled and setEnabled on TransparencyAttributes). This will [should] not give you any speed penalty, because of sorting is done on CPU anyway.

Yuri