Ramp

Ramp, sometimes called ramp lookup or gradient mapping, is a technique for mapping a scalar to a color through a 1D lookup texture. This is commonly used to map a luminance value to a color by using the luminance as the uv when sampling a gradient texture.

Texture orientation

In the below example, the gradient is baked into a 256x1 texture. For a vertical texture (1xN), the height should be used instead of the width, and it should be used to drive v instead of u.

Parameters:

  • t is the input value (often luminance).
  • ramp is a gradient which is used as the ramp lookup texture.
  • texel_size is 1 / ramp resolution and is used to ensure the sampling starts and ends half a pixel inside the texture. This can often be skipped.

Use cases:

  • Recoloring: Swap the ramp texture to restyle a material, enabling team colors, seasonal variants, damage states, etc.
  • Shading: Drive the lookup with N·L instead of luminance to get authored control over shadow color and transition sharpness.
  • Color over life: Feed a particle’s normalized lifetime into the ramp, changing its color as the particle ages.
  • Data visualization: Map a normalized value, such as height, temperature or density, to a color scale for heatmaps and debug views.

Related