Java Reference
In-Depth Information
of depth or z-axis values between the geometries. As a result, all the objects have become
visible and will be rendered, regardless of any occlusion and interception between them.
Next, alpha testing can be enabled by changing the third and fourth parameters in the
rendering attribute constructor so that it becomes, for example, RenderingAttributes(true,
true, ALPHA_TEST, RenderingAttributes.GREATER…). The results are given in Figure
23, which shows that some of the rectangles at different depth will not be rendered depend-
ing on the alpha test value, ALPHA_TEST, and the alpha value of the rectangle specified
in line 20 of Figure 20.
Specifically, the alpha value serves as a multiplying factor when it is used with the
TransparencyAttribute. If the transparency value in the TransparencyAttribute is 0.5f and the
alpha value in color4f is 0.3f, the value of transparency will be 0.15f. In the above example
when RenderingAttributes.GREATER is used as the fourth parameter in the rendering
attribute constructor, the rendering of the object will be carried out only if the associated
alpha values of the geometries are greater than the alpha test value set by the user.
Instead of using GREATER as in RenderingAttributes.GREATER, other possibilities
and their associated actions are listed below.
ALWAYS: Pixels are always drawn, irrespective of the alpha value. This is the default
and, effectively, disables alpha testing.
NEVER: Pixels are never drawn, irrespective of the alpha value.
EQUAL: Pixels are drawn if the pixel alpha value is equal to the alpha test value.
Figure 23. Results from render.java, after changing the third and fourth parameters in
RenderingAttributes(true,true,0.0f, RenderingAttributes.ALWAYS to RenderingAttributes(t
rue,true,ALPHA_TEST,RenderingAttributes.GREATER. The value of ALPHA_TEST is 0.4f
and 0.9f for the left and right diagram, respectively.
Search WWH ::




Custom Search