Title: 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


-----Original Message-----
From: Kelvin Chung [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 23, 2002 10:20 PM
To: [EMAIL PROTECTED]
Subject: Re: [JAVA3D] Transparency problem in 1.2.1


Hi Yuri,

    After further investigation I've closed this bug.
The original AppearanceTest has the scenegraph structure

       BG
     /...\
   O1, ...O8, T1

contains 9 Shape3D O1, ...O8, T1
where Oi are opaque objects and T1 is transparency object.
By default Java3D will render the opaque object first
follow by transparency object with so it appears
correct.

In the modified AppearanceTest the user add an OrderedGroup above
the BranchGroup as follows:

       OG
       |
       BG
     /...\
   T1, ...T8, O1

The specification did not mention very clear but
OrderedGroup will override the rendering order of all child and
grand children under it. So the shape under it will not render
in two pass as expected: first opaque follow by transparent
object with depth buffer write disable.

Thus for the following scene graph

               OG
            /      \
           /         \
        BG1           BG2
     /  |  \  \     /  |  \  \
    T1  O1  T2 O2   T3  O3  T4 O4

where Ti are transparency object and Oi are opaque object.
Java3D will NOT render in order of O1, O2, T1, T2, O3, O4, T3, T4.
Instead the rendering order within the children of BG1
can be random since they are not direct children of OG
and it is a grandchildren of OG.
Similarly for the rendering order within the children of BG2.
One thing Java3D gaurantee is that all the child under BG1
will render BEFORE BG2.

To get the effect of what you want, it can be workaround
by using another OrderedGroup, group together
the opaque and transparent object explicitly, then set
the RenderingAttributes depthBufferWriteEnable to false
for all transparency Shape3D appearance as follows:


               OG
            /      \
           /         \
        OG1            OG2
       /   \          /   \
     BG1  BG2       BG3   BG4
    /  \  /  \     /  \   /  \
   O1  O2 T1 T2   O3  O4 T3  T4
          |  |           |   |
          R  R           R   R

Where BG1, BG3 contains all opaque objects
and BG2, BG4 contains all transparency objects.
R is RenderingAttributes with depthBufferWrite disable.

Attach is the modified AppearanceTest to show how
it works.


Thanks.

- Kelvin
------------------
Java 3D Team
Sun Microsystems Inc.

Reply via email to