Lerp, or Linear Interpolation, is a node that outputs a value along a specified range. The Start and Stop values determine the limits of the range and the Step value determines a point between them. Lerp is in the Math category.
|Start||Number, Vec2, Vec3, Color||Starting point.|
|Stop||Number, Vec2, Vec3, Color||Stopping point.|
|Step||Number||The value (from 0 to 1) used to interpolate between Start and Stop.|
|Result||Number, Vec2, Vec3, Color||A value between Start and Stop.|
This example uses a Lerp node to gradually change the color of a sphere from red to blue over four seconds. The Start value has been set to red and the Stop value has been set to blue. The Step value determines what point between the two colors the node should output (0.5 would output purple).
At times, you may want the Start or Stop value to track a moving object. In this next example, an image will move from the center of the screen to the 2D position of a face over the first two seconds after an effect starts. The Start value (not to be confused with the Start node) has been set to 0,0 (the center of the screen) and the Stop value follows the 2D position of a face.
To pull the 2D position of a face, Get Position from a Face Sticker with the Anchor set to Face Center.
The Lerp node is a great tool for smoothing out a transition. This example shows how to smoothly track a cube to a user’s head. The Lerp node is outputting the current position of the cube. This value is then fed back into the node as the Start input so that every frame, the cube will be a set distance (0.1 in this example) between the Head Tracker and the cube’s previous position.
For this example, the Step value remains constant (the higher the number, the less of a delay there will be).