---
id: "lut-color-grading"
title: "3D LUT color grading"
aliases: [LUT, colour grading]
domain: "post"
stage: "post"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot, blender]
year_introduced: 2005
inputs: [ldr-image, hdr-image]
outputs: [ldr-image]
style: "both"
dynamic: "both"
cost: "cheap"
authority: "Selan"
url: "https://texelatlas.vercel.app/t/lut-color-grading/"
sources_verified_at: "2026-11-29"
---
# 3D LUT color grading (Selan)

> Stores an arbitrary colour transform in a 3D lookup table, usually 16 to 64 cells per axis, and applies it with one trilinear texture fetch per pixel. Any grade from Photoshop, DaVinci or OCIO can be baked in.

## Reach for it when

- bring a grade from davinci or photoshop into my engine
- need the same look across several tools and engines
- apply any colour transform in one cheap pass
- colourist handed me a look file to apply in realtime
- complex grading is too costly per pixel

## How it works

An identity LUT maps each RGB coordinate to itself. The artist grades a picture of the identity LUT in any colour tool, and the graded LUT then encodes the whole transform. At runtime the pixel's RGB is used as a 3D texture coordinate, with a half-texel offset and scale so values at 0 and 1 land on cell centres, and hardware trilinear filtering interpolates. Without 3D texture support, the LUT is packed as a 2D strip and the blue channel is interpolated manually between two slices. Shaper curves (log encoding) are used before the LUT when it must handle HDR values, because a linear mapping wastes resolution on highlights. The LUT should also bake the tonemapper for a single pass.

## When to use it

Choose it when grading must be authored in external tools, shared across engines, or you need a single cheap pass for an arbitrary look.

Prefer analytic grading (lift, gamma, gain) when parameters must animate or be tweaked at runtime. Place after [AgX](https://texelatlas.vercel.app/t/agx-tonemapping.md) or [ACES filmic tonemapping](https://texelatlas.vercel.app/t/aces-tonemapping.md) on LDR data, or bake the tonemapper into the LUT with a log shaper.

## Cost

cheap — One 3D texture fetch per pixel, negligible.
Measured GPU Weight: 3.37× baseline (light) — 0.111 ms median / 0.1218 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 2.16× baseline (light) — 0.0344 ms median (3.23× faster on L4).
Ampere A100 scaling: 2.27× baseline (light) — 0.0654 ms median (1.7× faster on A100).

## Failure modes

- Banding in smooth gradients with small LUT sizes or 8-bit storage
- Wrong half-texel mapping gives a visible tint on blacks and whites
- Trilinear interpolation of strongly non-linear grades produces hue errors between cells
- A display-referred LUT applied to HDR input clips highlights

## Engine support

- babylonjs: builtin — `imageProcessingConfiguration.colorGradingEnabled = true; colorGradingTexture = new BABYLON.ColorGradingTexture('x.3dl', scene)` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Materials/Textures/colorGradingTexture.ts, checked 2026-12-01)
- blender: builtin — `Color Management via OpenColorIO (OCIO config + Look LUTs)` (evidence: https://docs.blender.org/manual/en/5.2/render/color_management.html, checked 2026-12-01)
- godot: builtin — `Environment.adjustment_color_correction (Texture2D or Texture3D LUT)` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Environment.xml, checked 2026-12-01)
- threejs: official — `import { lut3D } from 'three/addons/tsl/display/Lut3DNode.js' (WebGL: LUTPass)` (evidence: https://github.com/mrdoob/three.js/blob/r187/examples/jsm/tsl/display/Lut3DNode.js, checked 2026-12-01)
- unity: builtin — `Volume > Add Override > Post-processing > Color Lookup (URP) / Tonemapping Mode = External (HDRP)` (evidence: https://github.com/Unity-Technologies/Graphics/blob/557f6ac22b948284f57ffae6a789751fd1f63620/Packages/com.unity.render-pipelines.universal/Runtime/Overrides/ColorLookup.cs, checked 2026-12-01) — URP Color Lookup takes a 2D strip or 3D texture.
- unreal: builtin — `Post Process Volume > Color Grading > Misc > Color Grading LUT` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/post-process-effects-in-unreal-engine, checked 2026-12-01)

## Dataflow

- Inputs: ldr-image, hdr-image
- Outputs: ldr-image
- Platforms: webgl2, webgpu, desktop-gpu, mobile-gpu, unity, unreal, godot, blender

## Presets

### Left: original. Right: the same grade baked into a 16x16x16 lattice and applied by trilinear lookup (glsl-fragment; rendered 2026-11-29)

```json
{
  "N": 16
}
```

```glsl
float hash(vec2 c){uvec2 u=uvec2(ivec2(floor(c)));uint h=u.x*1597334673u^u.y*3812015801u;h^=h>>15;h*=2246822519u;h^=h>>13;h*=3266489917u;h^=h>>16;return float(h)*(1./4294967296.);}
float lum(vec3 c){return dot(c,vec3(.2126,.7152,.0722));}
vec3 gam(vec3 c){return pow(clamp(c,0.,1.),vec3(1./2.2));}
vec3 img(vec2 p){
  vec3 c=mix(vec3(.12,.18,.34),vec3(.95,.72,.45),clamp(p.y+.5,0.,1.));
  vec2 q=p-vec2(-.03,.14); float rr=.16; float d=length(q)-rr;
  vec3 n=normalize(vec3(q/rr,sqrt(max(1.-dot(q,q)/(rr*rr),0.))));
  float l=clamp(dot(n,normalize(vec3(-.5,.6,.6))),0.,1.);
  c=mix(c,vec3(.85,.26,.2)*(.18+.9*l),smoothstep(.002,-.002,d));
  vec2 r=p-vec2(0.,-.2);
  if(abs(r.x)<.2&&abs(r.y)<.09) c=mix(vec3(.1,.35,.3),vec3(.93,.92,.85),smoothstep(-.3,.3,sin(r.x*340.+r.y*90.)));
  if(p.y<-.34&&p.y>-.42){ vec3 h=.5+.5*cos(6.2832*((p.x+.25)*2.+vec3(0.,.33,.67))); c=h; }
  c=mix(c,vec3(.97,.85,.2),smoothstep(.003,-.003,abs(p.x-.17)-.025)*step(.0,p.y)*step(p.y,.4));
  return c;
}

const float N=16.0; // P
vec3 grade(vec3 c){c=mix(c,c*c*(3.-2.*c),.75);float l=lum(c);
  return clamp(mix(c*vec3(.8,1.02,1.15),c*vec3(1.2,1.0,.75),smoothstep(.2,.8,l)),0.,1.);}
vec3 lut(vec3 c){vec3 f=clamp(c,0.,1.)*N,i=min(floor(f),vec3(N-1.)),w=f-i;
  vec3 a=i/N,d=vec3(1./N);
  vec3 x00=mix(grade(a),grade(a+vec3(d.x,0.,0.)),w.x),x10=mix(grade(a+vec3(0.,d.y,0.)),grade(a+vec3(d.x,d.y,0.)),w.x);
  vec3 x01=mix(grade(a+vec3(0.,0.,d.z)),grade(a+vec3(d.x,0.,d.z)),w.x),x11=mix(grade(a+vec3(0.,d.y,d.z)),grade(a+d),w.x);
  return mix(mix(x00,x10,w.y),mix(x01,x11,w.y),w.z);}
void mainImage(out vec4 fragColor,in vec2 fragCoord){
  vec2 uv=(fragCoord-.5*iResolution.xy)/iResolution.y;bool R=uv.x>0.;vec2 q=vec2(uv.x+(R?-.25:.25),uv.y);
  vec3 col=img(q);
  if(R)col=lut(col);
  if(abs(uv.x)<.0015)col=vec3(1.);fragColor=vec4(clamp(col,0.,1.),1.);
}
```

Attribution: written for this index

## Lineage

- extended by [Film emulation (spectral stock simulation)](https://texelatlas.vercel.app/t/film-emulation.md)

## Combines with

- [AgX](https://texelatlas.vercel.app/t/agx-tonemapping.md): The LUT grades the display-referred output of the tonemapper.
- [Oklab perceptual color space](https://texelatlas.vercel.app/t/oklab.md): Perceptual-space edits are baked into the LUT for fast playback.

## Sources

1. [primary] Jeremy Selan Using Lookup Tables to Accelerate Color Transformations. GPU Gems 2. https://developer.nvidia.com/gpugems/gpugems2/part-iii-high-quality-rendering/chapter-24-using-lookup-tables-accelerate-color (verified via http on 2026-11-29)
2. [implementation] AcademySoftwareFoundation (2010) AcademySoftwareFoundation/OpenColorIO. https://github.com/AcademySoftwareFoundation/OpenColorIO License: BSD-3-Clause. (verified via github on 2026-11-29)

## Cite this entry

Texel. "3D LUT color grading." https://texelatlas.vercel.app/t/lut-color-grading/ (accessed 2026-12-01).
