Lerp is the procedure to interpolate between two vectors with a specified weight. An example below
float weight; // the weight for lerping vec2 input1, input2; // the inputs to lerp between vec2 lerpResult = input1(1.0-weight)+input2(weight); |
In GLSL it’s named mix( genType, genType, float ) instead of lerp which can be misleading. But when testing, it actually works to use lerp instead of mix in GLSL shaders when running them on a Nvidia GeForce 8800GTS although it’s not recommended.
Here’s the OpenGL GLSL quick reference guide which contains all functions you can use inside of a shader (and much more).
http://www.opengl.org/sdk/libs/OpenSceneGraph/glsl_quickref.pdf

















Oh my god. This was a life saver.
I’ve been playing around with NVIDIA’s cg, modifying game files for Europa Universalis III and let me tell you, cg/glsl info is kind of hard to get.
Thank you for this page.
x*(1-s) + y*s can equivalently be written as x + s(y-x)
Doing this saves an operation.
Yes, nice catch. But it was merely an example of showing how lerp is done, and I tried to do it as simple as possible.
Thanks..I was gonna do it the hard way. lerp() is mix() ha! Thanks.