< Zurück | Inhalt | Weiter >

9.12.1 A warning about transparency

Consider carefully what you are trying to achieve if you choose to use transparency as an Appearance attribute in your scene. It is very difficult to know exactly what will be rendered by Java 3D in either NICEST or SCREEN_DOOR mode, and without some form of application−specific sorting algorithm, which must be carried out potentially on every frame, problems will probably occur.


The issues with transparency really do not reside at the Java3D level, but Java 3D has not done a good job of insulating the Java 3D developer from the underlying issues in the OpenGL/DirectX implementation. I am hopeful that Sun can address many of these issues in Java 3D 1.3.

image


Figure 9.19 Coloring = null, Material = null, Transparency = null


image


Figure 9.20 Coloring = green, Material = null, Transparency = null. Note that the QuadArray with per−vertex colors is unaffected

image


Figure 9.21 Coloring = null, Ambient: white Diffuse: white Emissive: blue, Transparency = null. Lighting is now active and affects the QuadArray with per−vertex colors


image


Figure 9.22 Coloring = null, Material = null. Transparency = 0—NICEST. Here we have set up transparency for both the Box (100% opaque) and the QuadArray (per−vertex transparency). Even though the QuadArray should be visible at the front of the Box, it is being rendered behind the Box. This would be a case that could be solved using a simple sorting algorithm because the centroid of the Box is behind the centroid of the QuadArray and hence it should be rendered before the QuadArray

image


Figure 9.23 Coloring = null, Material = null. Transparency = 0—SCREEN_DOOR. Here, when we switch to SCREEN_DOOR transparency, the rendering order problem disappears


image


Figure 9.24 Coloring = null, Material = null. Transparency = 0.5—NICEST. When the Box is semitransparent, the problem with rendering order is not apparent because you can see the QuadArray through the Box

image


Figure 9.25 Coloring = null, Material = null. Transparency = 0.5—SCREEN_DOOR. Using stippling to simulate transparency is not as realistic as using true color blending


image


Figure 9.26 Coloring = null, Material = null. Transparency = 0.8—NICEST. We have increased the transparency of the

Box and rotated it so that the QuadArray is now at the rear of the Box. No problems apparent here

image


Figure 9.27 Coloring = null, Material = null. Transparency = 0.8—SCREEN_DOOR. We have increased the transparency of the Box and rotated it so that the QuadArray is now at the rear of the Box. Using SCREEN_DOOR transparency, the QuadArray has now disappeared


image


Figure 9.28 Coloring = null, Ambient: white, Diffuse: white, Emissive: blue, Transparency = 0.5—NICEST. The scene renders correctly—but continuously renders, cycling over the back faces and then redrawing the front faces

image


Figure 9.29 Coloring = null, Ambient: white, Diffuse: white, Emissive: blue, Transparency = 0.5—SCREEN_DOOR. No problems apparent here