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

Signed Scaling

source register_bx2

Subtracts 0.5 from each channel and scales the result by 2.0. The name "bx2" comes from "bias times two," which is the operation it performs.

Register

Source register. For more about register types, see Registers.

Remarks

The contents of the register are not changed. The modifier is applied only to the data read from the register.

The signed scaling operation is applied to the data read from the register before the next instruction is executed. The operation is applied to all four color channels (RGBA) as follows:

y = 2(x – 0.5)

This operation is commonly used to expand data from [0.0 to 1.0] to [-1.0 to 1.0]. Using _bx2 on data outside the range 0 to 1 may produce undefined results.

This modifier is designed for use with the arithmetic instructions. This modifier is commonly used on inputs to the dot product instruction (dp3).

This modifier is mutually exclusive with Invert so it cannot be applied to the same register.

For shader versions 1.0 and 1.1, input arguments to any of the texture address instructions of the form texm3x2* and texm3x3* can use the _bx2 modifier.

For shader versions 1.2 and 1.3, the source register to any tex* instruction can use the _bx2 modifier.

Example

This example samples a texture, converts data to the range of -1 to +1, and calculates a dot product.

tex t0                        ; Read a texture color.
dp3_sat r0, t0_bx2, v0_bx2    ; Calculate a dot product.