< Zurück | Inhalt | Weiter >

9.8 RenderingAttributes

java.lang.Object

|

+−−javax.media.j3d.SceneGraphObject

|

+−−javax.media.j3d.NodeComponent

|

+−−javax.media.j3d.RenderingAttributes


Table 9.8 Capability bits for the RenderingAttributes class


ALPHA_TEST_FUNCTION

ALLOW_ALPHA_TEST_VALUE

ALLOW_DEPTH_ENABLE

OpenGL Reference: glAlphaFunc

The RenderingAttributes class allows pixels within the final rendered scene to be included or excluded based on the pixel Alpha (transparency) value (table 9.8).


Assuming an Alpha test value of A, the test conditions listed in table 9.9 and shown in figure 9.16 are available.

image


Figure 9.16 Using RenderingAttributes to control the portions of a QuadArray that are rendered. Vertex 0 has transparency 0.0, vertex 1 has transparency 0.2, vertex 2 has transparency 0.8, and vertex 3 has transparency 1.0. In all cases the Alpha test value was set to 0.5


Table 9.9 Alpha test modes


Alpha test function

Meaning

ALWAYS

Always render pixel regardless of A

EQUAL

Render pixel if pixel transparency = A

GREATER

Render pixel if pixel transparency > A

GREATER_OR_EQUAL

Render pixel if pixel transparency >= A

LESS

Render pixel if pixel transparency < A

LESS_OR_EQUAL

Render pixel if pixel transparency <= A

NEVER

Never render pixel regardless of A

NOT_EQUAL

Render pixel if pixel transparency != A

The interpolation of transparency values across primitives (quads or triangles) can sometimes be surprising. Figure 9.17 illustrates what happens to a QuadArray when it is rotated. In this case vertexes 0 and 1 have a transparency of 0.0, and vertexes 1 and 2 have a transparency of 1.0.

image


Figure 9.17 The lower two vertices have transparency 0.0, while the upper two vertices have transparency 1.0. The Alpha test value is 0.5 and Alpha test function is LESS. Note that, as the QuadArray rotates, the transparency interpolation changes as a function of the rotation and an apparent spike appears in the middle of the quad