Texture Coordinate Transformations
Texture coordinate transformations are enabled for the latest Direct X release.
Texture transforms are vertex-level transformation operations. These operations can be performed by any transform and lighting-enabled HAL driver and by any HAL device type.
Texture transforms are enabled by defining 4X4 matrices associated with each texture stage. All of the key state and data structures used by the software implementation of the geometry pipeline are available at the DDI level.
Using texture transformations, texture coordinates can be moved, relative to the vertices they are being drawn from. The texture transform describes how the texture coordinates are moved inside the texture map. Every time a texture transform is applied, the matrix changes the coordinates of the texture. The standard world matrix is used in these transformations.
At the API level, the IDirect3DDevice7::SetTransform method (described in the Direct3D SDK documentation) defines the texture transform matrix associated with the texture currently bound to the i-th texture stage. This matrix should be applied to the texture coordinates of that texture during rendering. Note that the same vertex-level texture coordinate set can be used at different stages with a separate texture transform matrix that may apply different textures.
The operation of the texture transform is controlled by the IDirect3DDevice7::SetTextureStageState method (described in the Direct3D SDK documentation) using the D3DTSS_TEXTURETRANSFORMFLAGS flag.
The D3DTEXTURETRANSFORMFLAGS enumerated type, described in the DirectX SDK documentation, is used to control the dimension of the texture coordinate set that is generated by the texture coordinate transformation operation, and to control whether any perspective division should be applied to it.
D3DTTFF_DISABLE indicates that the texture coordinates are passed directly to the hardware.
The number of the D3DTTFF_COUNTn flag signals how many texture coordinates are going to be present. Note that this does not necessarily equate to the dimension of the textures themselves, if projected textures are used.
If projected textures are used, the D3DTTFF_PROJECTED flag is set to indicate that the texture coordinates are to be divided by the last (COUNTth) element of the texture coordinate set. Thus, for a 2D projected texture, the count is three, because the first two elements are divided by the third, resulting in two floats for a 2D texture lookup. That is, both D3DTTFF_COUNT2 and D3DTTFF_COUNT3 | D3DTTFF_PROJECTED refer to a 2D texture.
For nonprojected textures:
D3DTTFF_COUNT1 indicates that the rasterizer should expect 1D texture coordinates.
D3DTTFF_COUNT2 indicates that the rasterizer should expect 2D texture coordinates.
D3DTTFF_COUNT3 indicates that the rasterizer should expect 3D texture coordinates.
D3DTTFF_COUNT4 indicates the rasterizer should expect 4D texture coordinates.
The first byte encodes a count of texture coordinates expected to be used by the texture at a particular stage. Setting this to zero causes no texture transformation to be applied even if one was defined by the IDirect3DDevice7::SetTransform method. This is the number that is output from the texture coordinate transform stage.
The number of texture coordinates passed into the texture transform is defined by the Direct3D API FVF code.
D3DTSS_TEXTURETRANSFORMFLAGS defaults to D3DTFF_DISABLED with no D3DTTFF_PROJECTED flag set. The texture transform matrices default to 4X4 identity matrices.
On nontransform-and-lighting HAL devices (that is, those that require transformation operations on the host processor), the output vertices are provided to the driver with the appropriate DDI-level FVF code that may differ from the one specified at the API level. Devices that do not support hardware-accelerated transform and lighting may still do projected textures, and therefore the drivers must still respond to the D3DTSS_TEXTURETRANSFORMFLAGS.