GXSetAlphaCompare

Syntax

#include <revolution/gx.h>

void GXSetAlphaCompare(
    GXCompare     comp0,
    u8            ref0,
    GXAlphaOp     op,
    GXCompare     comp1,
    u8            ref1 );

Arguments

comp0 Comparison subfunction0. Applicable values are as follows:
Name Comparison Method for subfunction0
GX_NEVER Always FALSE.
GX_LESS ( ( alpha_src < ref0 )
GX_LEQUAL ( ( alpha_src <= ref0 )
GX_EQUAL ( ( alpha_src == ref0 )
GX_NEQUAL ( ( alpha_src != ref0 )
GX_GEQUAL ( ( alpha_src >= ref0 )
GX_GREATER ( ( alpha_src > ref0 )
GX_ALWAYS Always true
ref0 Reference value for subfunction0. An 8-bit value.
op An operator for combining subfunction0 and subfunction1. Applicable values are as follows:
Name Logical Method
GX_AOP_AND ( ( subfunction0 ) AND ( subfunction1 )
GX_AOP_OR ( subfunction0 ) OR ( subfunction1 )
GX_AOP_XOR ( subfunction0 ) XOR ( subfunction1 )
GX_AOP_XNOR ( subfunction0 ) XNOR ( subfunction1 )
comp1 Comparison subfunction1. Applicable values are as follows:
Name Comparison Method for subfunction1
GX_NEVER Always false
GX_LESS ( ( alpha_src < ref1 )
GX_LEQUAL ( ( alpha_src <= ref1 )
GX_EQUAL ( ( alpha_src == ref1 )
GX_NEQUAL ( ( alpha_src != ref1 )
GX_GEQUAL ( ( alpha_src >= ref1 )
GX_GREATER ( ( alpha_src > ref1 )
GX_ALWAYS Always true
ref1 Reference value for subfunction1. An 8-bit value.

Return Values

None.

Description

This function sets the arguments for the alpha comparison function which uses alpha output from the last active texture environment (TEV) stage. The number of active TEV stages is specified using the GXSetNumTevStages function.

The output alpha can be used in blending equations (see the GXSetBlendMode function) to control how input and target (frame buffer) pixels are blended.

The alpha comparison is:

alpha_pass = ( alpha_src ( comp0 ) ref0 ) ( op ) ( alpha_src ( comp1 ) ref1 )

Where alpha_src is the alpha from the last active TEV stage. As an example, you can implement these equations:

alpha_pass = ( alpha_src > ref0 ) AND ( alpha_src < ref1 )

or

alpha_pass = ( alpha_src > ref0 ) OR ( alpha_src < ref1 )

The Z compare can occur either before or after texturing. See the GXSetZCompLoc function. In the case where Z comparison occurs before texturing, the Z value is written based only on the Z test. The color is written if both the Z and alpha tests pass.

When Z comparisons occur after texturing, the color and Z are written if both the Z and alpha tests pass. When using texture to make cutout shapes (like billboard trees) that need to be correctly Z buffered, you should configure the pipeline for Z buffering after texturing.

See Also

GXSetNumTevStages, GXSetTevAlphaIn, GXSetTevAlphaOp, GXSetBlendMode, GXSetZCompLoc

Revision History

2008/05/12 Corrected the old function name, GXSetTevStages, to the new name, GXSetNumTevStages
2006/03/01 Initial version.


CONFIDENTIAL