< Zurück | Inhalt | Weiter >

14.5 Using transparent geometry with transparent texture images

The Texture class allows texture images to have red, green, blue, and alpha (transparency) channels through the RGBA mode. Appearances (and hence geometry) can also have transparency information, either through per−vertex COLOR_4 colors, or through the TransparencyAtttributes NodeComponent. Figures 14.25– 14.27 illustrate what happens when partially transparent images are applied to partially transparent Shape3Ds.


The easiest way to use transparent images is to use the GIF image format, which can include a transparent color. Most bitmap editors, such as JASC PaintShop Pro or Adobe Photoshop, can save GIF images with a transparent color.


Figures 14.25–14.27 were generated using the AppearanceTest example application. The Box had the appearance attributes shown on table 14.5.


Table 14.5 Box appearance attributes


Transparency: 0.5, NICEST

Material: Ambient = white, Diffuse = white, Emissive

= blue, Specular = black, Shininess = 1

Texture: MagFilter = BASE_LEVEL_LINEAR, MinFilter = MULTI_LEVEL_LINEAR

MIPMAPs were enabled.

The front face (smaller) of the cube uses per−vertex colors with transparency and hence is unaffected by the overall TransparencyAttributes of the Box’s Appearance.

Figure 14.25 is provided for contrast; it uses the opaque texture image (texture0n.jpg).

image


Figure 14.25 Shape3D with an opaque image applied (texture0n.jpg) from AppearanceTest. 1 = MODULATE, 2 = DECAL, 3 = BLEND, 4 = REPLACE


Figure 14.26 uses a transparent version (texture2n.gif) of the original texture image. The white background of the texture image has been marked as a transparent color in the GIF image.


image


Figure 14.26 Shape3D with transparent image applied (texture2n.gif) from AppearanceTest. 1 = MODULATE, 2 = DECAL, 3 = BLEND, 4 = REPLACE


Figure 14.27 uses the transparent texture image but also disables back−face removal using PolygonAttributes.CULL_NONE. Frame 2 (DECAL) suffered from continuous redraw because the back faces were redrawn over the front faces, and then the back faces were redrawn.

image


Figure 14.27 Transparency = 0.2, PolygonAttributes.CULL_NONE. Shape3D with transparent image applied (texture2n.gif) from AppearanceTest. 1 = MODULATE, 2 = DECAL, 3 = BLEND, 4 = REPLACE