?/TD>
Microsoft DirectX 9.0

texbem (Pixel Shader)


Apply a fake bump environment-map transform. This is accomplished by modifying the texture address data of the destination register, using address perturbation data (du,dv), and a 2-D bump environment matrix.

Syntax

texbem (Pixel Shader) destsrc

Registers

dest
Destination register.
src
Input source register.

Remarks

Pixel shader versions1_11_21_31_42_02_x2_sw3_03_sw
texbemxxx

The red and green color data in the src register is interpreted as the perturbation data (du,dv).

This instruction transforms red and green components in the source register using the 2-D bump environment-mapping matrix. The result is added to the texture coordinate set corresponding to the destination register number, and is used to sample the current texture stage.

This operation always interprets du and dv as signed quantities. For versions 1_0 and 1_1, the Signed Scaling input modifier (_bx2) is not permitted on the input argument.

This instruction produces defined results when input textures contain signed format data. Mixed format data works only if the first two channels contain signed data. For more information about surface formats, see D3DFORMAT.

This can be used for a variety of techniques based on address perturbation, including fake per-pixel environment mapping and diffuse lighting (bump mapping).

When using this instruction, texture registers must follow the following sequence.

// The texture assigned to stage t(n) contains the (du,dv) data.
// The texture assigned to stage t(m) is sampled.
tex     t(n)					
texbem  t(m),  t(n)      where m > n

The calculations done within the instruction are shown below.

// 1. New values for texture addresses (u',v') are calculated.
// 2. Sample the texture using (u',v').
u' = TextureCoordinates(stage m)u + 
      D3DTSS_BUMPENVMAT00(stage m)*t(n)R +
	  D3DTSS_BUMPENVMAT10(stage m)*t(n)G
	  
v' = TextureCoordinates(stage m)v + 
      D3DTSS_BUMPENVMAT01(stage m)*t(n)R +
	  D3DTSS_BUMPENVMAT11(stage m)*t(n)G

t(m)RGBA = TextureSample(stage m) 
// using (u',v') as coordinates.

Register data that has been read by a texbem (Pixel Shader) or texbeml instruction cannot be read later, except by another texbem (Pixel Shader) or texbeml.

// This example demonstrates the validation error caused by t0 being reread:
ps_1_1
tex t0
texbem t1, t0
add r0, t1, t0

(Instruction Error) (Statement 4) Register data that has been read by 
texbem or texbeml instruction cannot be read by other instructions.

Examples

Here is an example shader with the texture maps identified and the texture stages identified.

ps_1_1
tex t0              ; define t0 to get a 2-tuple DuDv
texbem t1, t0       ; compute (u',v')
                    ; sample t1 using (u',v')
mov r0, t1          ; output result

texbem (Pixel Shader) requires the following textures in the following texture stages.

Stage 0 is assigned a bump map with (du, dv) perturbation data.

Stage 1 uses a texture map with color data.

This instruction sets the matrix data on the texture stage that is sampled.

This is different from the functionality of the fixed function pipeline where the perturbation data and the matrices occupy the same texture stage.

Instruction Information

Minimum operating systems Windows 98


© 2002 Microsoft Corporation. All rights reserved.