lrp

DirectX8

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

lrp

Interpolates linearly between the second and third source registers by a proportion specified in the first source register.

lrp dest, src0, src1, src2

Registers

Argument Description RegistersVersion
vn cn tn rn
dest Destination register x 1.0
x x 1.1, 1.2, 1.3
x 1.4
src0, src1, src2 Source register x x x x 1.0, 1.1, 1.2, 1.3
x x 1.4 phase 1
x x x 1.4 phase 2

To learn more about registers, see Registers.

Remarks

This instruction performs the linear interpolation based on the following formula.

dest = src0 * src1 + (1-src0) * src2
// which is the same as
dest = src2 + src0 * (src1 - src2)

Example

This example is for illustration only. The C code accompanying the shader has not been optimized for performance. It can use helper functions from the Sample Framework. The sample framework is the foundation on which many of the samples are built.

// This example combines a texture color with a diffuse color value.

// The shader is shown below.
ps.1.0              // Version instruction.
tex t0              // Declare texture.
lrp r0, t0, v0, t0  // Blend from v0 to t0 by t0 amount.

// The input colors and the output colors are shown below. The first image
// (src0) determines the amount of the second image (src1) and the third image
// (src2) that are blended to make the final image (dest). Where the first image
// is white, the second image appears in the output. Where the first image is 
// black, the third images appears in the output. Where the first is gray, the 
// final image contains color values from the second and third image.

// Additional code loads the texture in texture stage 0. LPDIRECT3DDEVICE8 m_pd3dDevice; // initialize the pointer LPDIRECT3DTEXTURE8 m_pTexture0; // a pointer to the texture. TCHAR strPath[512] = "textureFile.jpg"; D3DUtil_CreateTexture( m_pd3dDevice, strPath, &m;_pTexture0, D3DFMT_R5G6B5 ); m_pd3dDevice->SetTexture( 0, m_pTexture0 );