Lerp

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

Please share:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Current
  • LinkedIn
  • Live
  • MySpace
  • Netvibes
  • StumbleUpon
  • Twitter
  • Reddit
  • Technorati
  • Yahoo! Bookmarks

4 thoughts on “Lerp

  1. ancestral

    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.

    Reply
  2. admin Post author

    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.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>