Title: RE: [JAVA3D] Transparency and Ordered Groups (solution)

Hey folks,

Regarding the transparency sorting problem I described in my message from Friday 1/25, we have found a reasonable solution.  See the copied message below for details on the problem.

To recap, we want to render a standard transparency-sorted scene as BranchGroup1, followed by some additional geometry without depth testing ("on top") as BranchGroup2.  It makes sense to use an OrderedGroup node to impose a rendering order, but for reasons unknown, Java 3D will not perform sorting on the grandchildren of an OrderedGroup.

Our solution is not to use an OrderedGroup node to impose a rendering order on BranchGroup1 and BranchGroup2, but rather to render BranchGroup2 from an overridden version of postRender() on Canvas3D.  This method is called after the scene graph is rendered, but before the back buffer is displayed.  Since there is no OrderedGroup, transparency sorting works fine.

However, rendering geometry through postRender() does make hit testing a bit more complicated, since that geometry must be dealt with separately.

- Mauricio

-----Original Message-----
From: Mauricio Vives [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 25, 2002 12:30 PM
To: [EMAIL PROTECTED]
Subject: [JAVA3D] Transparency and Ordered Groups


Kelvin and other interested readers,

This message is in regards to Kelvin's response on Wednesday to Yuri about a problem we are having using basic transparency sorting and OrderedGroup nodes.  By "basic" transparency sorting, I mean the default behavior of rendering transparent objects after opaque objects, a feature available even before Java 3D 1.3.  You mentioned that any nodes under an OrderedGroup node will not be sorted; in effect, they will be rendered at random. 

Let me explain in greater detail what we are trying to do.  We have a set of objects (BranchGroup1) that can be opaque and/or transparent.  In addition, we have another set of objects (BranchGroup2) that we want to appear "on top" of all the other geometry.  However, both BranchGroup1 and BranchGroup2 can occupy the same 3D space.  In order to achieve the desired effect, we need to do the following:

1) Render BranchGroup1, with opaque objects first, then transparent objects with the depth buffer locked.
(this is basic transparency sorting, which Java 3D provides)

2) Render BranchGroup2, but with depth testing disabled.
(this will make BranchGroup2 appear visible "through" any geometry in BranchGroup1, even if they occupy the same space)

Thus, we need to use an OrderedGroup node to force BranchGroup1 to be rendered before BranchGroup2, but we also need basic transparency sorting for the children of BranchGroup1.  However, as you mentioned in your response, no automatic sorting would be performed under BranchGroup1 because it resides under an OrderedGroup node.

You also mentioned that we could simply perform our own sorting to separate transparent and opaque objects.  Though this would be difficult, it can be done.  However, if I understand you correctly, we would still not be able to take advantage of the "full" transparency sorting feature of Java 3D 1.3, and I don't think it would be reasonable for us to implement that feature ourselves (particularly since the Java 3D team has already done the work).

I see no reason why Java 3D would not support the ability to do transparency sorting of the *grandchildren* of OrderedGroup nodes (or any other kind of sorting).  Is there a reason why Java 3D can't do this?  I would suggest this as a future Java 3D enhancement, if it is possible.

Note that I agree that if there are transparent objects spread around the scene graph (under various OrderedGroup nodes), then even the enhancement I am suggesting would not lead to the proper transparency effect.  However, as I explained above, with our application it would not matter.

Kelvin, thanks for your help so far, and for any additional information you can give us.

- Mauricio

Reply via email to