texbeml

DirectX8

Microsoft DirectX 8.1 (pixel shader versions 1.0, 1.1, 1.2, 1.3)

texbeml

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

texbeml dest, src

Registers

Argument Description RegistersVersion
vn cn tn rn
dest Destination register x 1.0, 1.1, 1.2, 1.3
src Source register x 1.0, 1.1, 1.2, 1.3

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

To learn more about registers, see Registers.

Remarks

This instruction transforms the 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. A luminance correction is applied using the luminance value and the bias texture stage values. The result is used to sample the current texture stage.

This can be used for a variety of techniques based on address perturbation such as fake per-pixel environment mapping.

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 mixed format data. For more information about surface formats, see D3DFORMAT.

// When using this instruction, texture registers must follow the following sequence.
// The texture assigned to stage tn contains the (du,dv) data.
// The texture assigned to stage t(m) is sampled.
tex     t(n)					
texbeml t(m),  t(n)      where m > n


// This example shows the calculations done within the instruction.
// 1. New values for texture addresses (u',v') are calculated.
// 2. Sample the texture using (u',v')
// 3. Luminance correction is applied.

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.

t(m)RGBA = t(m)RGBA*[t(n)B*(D3DTSS_BUMPENVLSCALE(stage m) + D3DTSS_BUMPENVLOFFSET(stage m))]

Note  When using texbem or texbeml, do not re-read the source register later in the shader because the data within the register might be corrupted. The shader validation allows this even though the result will be undefined.

Example

// Here is an example shader with the texture maps identified and
// the texture stages identified.
ps.1.0
tex t0              ; define t0 to get a 2-tuple DuDv
texbeml t1, t0      ; compute (u',v')
                    ; apply luminance correction                    
                    ; sample t1 using (u',v')
mov r0, t1          ; output result


// This example requires the following textures in the following texture stages.
//
// Stage 0 is assigned a bump map with (du, dv) perturbation data.
//
// Stage 1 is assigned a texture map with color data.
//
// texbeml 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.