Lookup Tables (LUT)
Lookup Table (LUT) is a way to remap complex lighting outputs or color responses using precomputed textures.
Instead of recalculating light equations every frame, LUT store color or lighting relationships inside a texture, which the shader simply samples at runtime.
This technique is used for stylized rendering and color grading.
Visual demo¶
Complete per-vertex and per-pixel implementations, with detailed comments, are available on Patreon.
// Pseudo-code (Complete per-vertex and per-pixel implementations, with detailed comments, are available in the related Patreon post)
// Input lighting color
inputColor = (r, g, b)
// Sample LUT per channel (1D lookup along X axis)
lutColor.r = sampleLUT(inputColor.r)
lutColor.g = sampleLUT(inputColor.g)
lutColor.b = sampleLUT(inputColor.b)
// Blend original lighting with LUT-mapped result
finalColor = lerp(
inputColor,
lutColor × inputColor,
LutTransition
)
// Output color after LUT coloring
return finalColor
Basic idea¶
A Lookup Table (LUT) acts as a color transformation map. Each lighting value (or color channel) is used as a coordinate to fetch precomputed color information from a texture.
This allows to fine-tune the lighting output. Without the actual lighting setup change it’s possible to set the tone remapping to stylize the project visuals.
Typical workflow:
- Compute lighting normally (e.g., Blinn-Phong, Lambertian, etc.)
- Use the lighting color or intensity as input to a LUT texture
- Sample the LUT and blend the result with the original lighting
- Adjust the blending strength to control stylization
LUT Equation¶
C_output = lerp(C_in, T(C_in) × C_in, α)
Where:
- C_in: input lighting color
- T(C_in): texture lookup from LUT
- α: LUT blending factor (transition control)
🔗 Related Functions¶
❤️ Support Shader Story¶
If this article helped you, consider supporting the project on Patreon: you’ll get access to the related source files and reference cheat-sheets.
Your support helps keep this library open and free for everyone.