lrp
Direct3D 8 - Pixel Shader - Instructions - lrp
Last edited 2026-02-20
The lrp instruction returns an interpolation of values between x and y, depending on t.
The lrp syntax looks like this:
lrp r, x, y, t;
(This instruction returns a value from the given mathematical function: r = x + (y - x) * t)
r: Value to which the final result will be assigned.
x: First value.
y: Second value.
t:Parameter controlling which result to return. Set to 0.0 to return x, set to 1.0 to return y, and set to 0.5 to return the midpoint (between x and y).
Example code:
texture T_Image; // <- Main texture
technique tech_main
{
pass P0
{
Texture[0] = <T_Image>;
PixelShader = asm
{
ps.1.1; // <- Pixel shader version
def c0, 1.0, 0.0, 0.0, 0.5; // <- Declaration of a constant 0, it's red color
def c1, 0.0, 0.0, 1.0, 0.0; // <- Declaration of a constant 1, it's blue color
tex t0; // <- Load the T_Image texture
lrp r0, c0, c1, c0.a; // <- Linear interpolation between red and blue colors and assigning this to result
mov r0.a, t0.a;
};
}
}
This example requires the following in the .XML file:
- Flag <dx8>yes</dx8>
(More information about .XML files can be found here)
Details table:
|
Type |
Instruction |
Description |
Instruction slots |
ps.1.0 |
ps.1.1 |
ps.1.2 |
ps.1.3 |
ps.1.4 |
Note |
|
asm |
Linear interpolate |
1 |
Yes |
Yes |
Yes |
Yes |
Yes |
Returns linear interpolate value between x and y, depending on t. |
Created with the Personal Edition of HelpNDoc: Maximize Your CHM Help File Capabilities with HelpNDoc