GXSetTexCoordGen2

Syntax

#include <revolution/gx.h>

void GXSetTexCoordGen2( 
    GXTexCoordID   dst_coord,
    GXTexGenType   func, 
    GXTexGenSrc    src_param,
    u32            mtx,
    GXBool         normalize,
    u32            postmtx );

Arguments

dst_coord Name of the texture coordinate to be generated. Accepted values are: GX_TEXCOORD0, GX_TEXCOORD1, GX_TEXCOORD2 through GX_TEXCOORD7.
func Feature used to generate texture coordinates. Accepted values are:
Name Type of Texture Coordinate Generation
GX_TG_MTX2x4 Source attributes are converted into a 2x4 matrix.
GX_TG_MTX3x4 Source attributes are converted into a 3x4 matrix.
GX_TG_BUMP0-7 Embossed-style bump texture coordinates.
GX_TG_SRTG R (red)/G (green) components from color channel output.
src_param Name of source attributes used to generate texture coordinates.
Features Specifiable values for src_param are:
GX_TG_MTX3x4
GX_TG_MTX2x4
GX_TG_POS (Position coordinates)
GX_TG_NRM (Normal vector)
GX_TG_BINRM (Binormal vector)
GX_TG_TANGENT (Tangent)
GX_TG_TEX0-7 (Input texture coordinates)
GX_TG_BUMP0-7 GX_TG_TEXCOORD0-6
GX_TG_SRTG GX_TG_COLOR0
GX_TG_COLOR1
mtx
Features Specifiable values for mtx are:
GX_TG_MTX2x4
GX_TG_MTX3x4
GX_TEXMTX0-9, GX_IDENTITY
GX_TG_BUMP0-7 Not used.
GX_TG_SRTG Not used.
normalize Specifies whether or not to normalize texture coordinates after conversion on the first path (GX_TG_MTX* only).
postmtx Specifies the post conversion matrix for multiplying texture coordinates by (GX_TG_MTX* only).
Specifiable values are GX_PTTEXMTX0-19 and GX_PTIDENTITY.

Return Values

None.

Description

This function is an expanded version of the GXSetTexCoordGen function which can specify options for generating texture coordinates.

The first four arguments are identical to those for the GXSetTexCoordGen function and operate in the same way. Only the new arguments are reviewed here. All other requirements specified in the GXSetTexCoordGen function still apply for the GXSetTexCoordGen2 function.

The new options apply only for ordinary texture coordinate generation, where the type is either GX_TG_MTX2x4 or GX_TG_MTX3x4. They do not work for light-based texgens or emboss texgens.

The normalize argument allows the calculated texture coordinate to be normalized after being multiplied by mtx, the first-pass transformation. The following calculation is performed (where [Stn, Ttn, Qtn] is the texture coordinate after the first-pass transformation):

After the optional normalization step, the texture coordinate is then multiplied by the 3x4 matrix, postmtx. This matrix is referred to as the post-transform matrix (see PTMatrix, below).

There are certain limitations when a vertex contains only position and one texture coordinate and the texgen type is GX_TG_MTX2x4. In this special performance case, normalization is not performed (even when specified). In addition, the value of Qtn is assumed to be 1.0, and Qt'n is not calculated.

This step results in a texture coordinate for the texture lookup.

The post-transform matrices are separate from the first-pass matrices. They are stored in a separate memory area in the same format as the first-pass matrices except that all matrices have three rows.
When the texture coordinate generation type is GX_TG_MTX3x4, the actual 2D texture coordinate calculation is carried out by dividing S and T coordinates by Q after post-conversion multiplication has been performed.

See Also

GXSetNumTexGens, GXSetTexCoordGen, GXSetVtxDesc, GXSetTevOrder

Revision History

2008/09/08 Added information about the method of calculating 2D coordinates when using GX_TG_MTX3x4.
2007/06/11 Added a link to GXPTTexMtx, the post-transform matrix enumerator. Corrected typos.
2006/03/01 Initial version.


CONFIDENTIAL