?/TD>
Microsoft DirectX 9.0

texcrd (Pixel Shader)


Copies texture coordinate data from the source texture coordinate iterator register as color data in the destination register.

Syntax

texcrd (Pixel Shader) destsrc

Registers

dest
Destination register.
src
Input source register.

Remarks

Pixel shader versions1_11_21_31_42_02_x2_sw3_03_sw
texcrdx

This instruction interprets coordinate data as color data (RGBA).

No texture is sampled by this instruction. Only texture coordinates set on this texture stage are relevant.

When using texcrd (Pixel Shader), keep in mind the following detail about how data is copied from the source register to the destination register. The source texture coordinate register (t#) holds data in the range [-D3DCAPS9.MaxTextureRepeat, D3DCAPS9.MaxTextureRepeat], while the destination register (r#) can hold data only in the (likely smaller) range [-D3DCAPS9.PixelShader1xMaxValue, D3DCAPS9.PixelShader1xMaxValue]. Note that for pixel shader version 1_4, D3DCAPS9.PixelShader1xMaxValue must be a minimum of eight. The texcrd (Pixel Shader) instruction, in the process of clamping source data that is out of range of the destination register, is likely to behave differently on different hardware. The first pixel shader version 1_4 hardware on the market will perform a special clamp for values outside of range. This clamp is designed to produce a number that can fit into the destination register, but also to preserve texture addressing behavior for out-of-range data (see D3DTEXTUREADDRESS) if the data were to be subsequently used for texture sampling. However, new hardware from different manufacturers might not exhibit this behavior and might just chop data to fit the destination register range. Therefore, the safest course of action when using pixel shader version 1_4 texcrd (Pixel Shader) is to supply texture coordinate data only into the pixel shader that is already within the range [-8,8] so that you do not rely on the way hardware clamps.

Unlike texcoord, texcrd (Pixel Shader) does not clamp values between 0 and 1.

Rules for using texcrd (Pixel Shader):

  1. The same .xyz or .xyw modifier must be applied to every read of an individual t(n) register within a texcrd (Pixel Shader) or texld instruction.
  2. The fourth channel result of texcrd (Pixel Shader) is unset/undefined in all cases.
  3. The third channel is unset/undefined for the xyw_dw case.

Examples

The complete set of allowed syntax for texcrd (Pixel Shader), taking into account all valid source modifier/selector and destination write mask combinations, is shown below. Note that the .rgba and .xyzw notation can be used interchangeably.

Copies first three channels of texture coordinate iterator register, t(n), into r(m). The fourth channel of r(m) is uninitialized.

texcrd  r(m).rgb, t(n).xyz  

// Produces the same result as the previous instruction.
texcrd  r(m).rgb, t(n)

Puts first, second, and fourth components of t(n) into first three channels of r(m). The fourth channel of r(m) is uninitialized.

texcrd  r(m).rgb, t(n).xyw

Here is a projective divide example using the _dw modifier.

This example copies x/w and y/w from t(n) into the first two channels of r(m). The third and fourth channels of r(m) are uninitialized. Any data previously written to the third channel of r(m) will be lost. Data in the fourth channel of r(m) is lost due to the phase marker. For version 1_4, the D3DTTFF_PROJECTED flag is ignored.

texcrd  r(m).rg,  t(n)_dw.xyw

Instruction Information

Minimum operating systems Windows 98


© 2002 Microsoft Corporation. All rights reserved.