Linear-space rendering and gamma correction
Do lighting, blending and filtering on values proportional to physical light, decoding sRGB inputs on read and encoding the result for display only at the end.
Also known as linear workflow, gamma-correct rendering, sRGB framebuffer, linear light
In the family Post-processing, color & imaging, colour management
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Built in | THREE.ColorManagement.enabled; renderer.outputColorSpace = THREE.SRGBColorSpace docs |
| Babylon.js 9.38.0 | Built in | PBRMaterial shades in linear space with automatic sRGB-to-linear texture conversion docs |
| Godot 4.7 | Built in | Forward+ and Mobile renderers shade in linear HDR; sRGB textures decode automatically docs |
| Unity | Built in | Project Settings > Player > Other Settings > Color Space = Linear docs |
| Unreal 5.7 | Built in | Project Settings > Rendering > Working Color Space (linear HDR rendering with sRGB and OpenColorIO transforms) docs |
| Blender 5.2 | Built in | Render Properties > Color Management (scene-linear working space) docs |
| WebGPU W3C | Built in | Texture formats rgba8unorm-srgb / bgra8unorm-srgb (hardware sRGB decode/encode) docs |
| Metal | Built in | MTLPixelFormat.rgba8Unorm_srgb / bgra8Unorm_srgb (hardware sRGB decode/encode) docs |
How it works
Display values (sRGB, roughly a 2.2 power curve) are perceptually spaced, not proportional to emitted light, so adding or averaging them gives wrong brightness. A linear workflow keeps every arithmetic stage in linear radiometric units: colour textures tagged sRGB are decoded when sampled (hardware does this for sRGB texture formats, including correct filtering), data textures such as normals, roughness and masks stay untouched, lighting accumulates in a floating-point linear buffer, and a final step applies tone mapping (see AgX, Khronos PBR Neutral tone mapper) and the sRGB opto-electronic transfer on output, either through an sRGB framebuffer or a manual shader function. Constant colours picked by artists in a UI are also decoded first. The same discipline applies to blending, mipmapping, MSAA resolve and bloom, which are only correct on linear data; the sRGB piecewise curve (a linear toe plus 2.4 exponent) is used rather than a plain 2.2 power when exact round trips matter.
When to choose it
Reach for it when
- my lighting looks too dark and contrasty in mid tones
- blended colours look muddy or too dark in the middle
- gradient between two saturated colours dips in brightness
- textures look washed out after adding lights
- alpha blended edges show dark fringes around sprites
Use it in every renderer, always; it is a prerequisite for physically plausible lighting, correct falloff, accurate alpha blending and GGX / Trowbridge-Reitz normal distribution-style PBR to look right. Add 3D LUT color grading and a tonemapper after it rather than instead of it. Choose a wider working gamut and HDR display output (PQ / BT.2100) only when targeting HDR panels; Oklab perceptual color space is the space for perceptual operations such as gradients, not for light transport.
Field marks
- Washed-out, over-bright mid-tones when lighting is computed on sRGB-encoded textures
- Dark fringes or halos around alpha-blended edges and particles blended in gamma space
- Banding in dark regions when linear data is stored in an 8-bit non-sRGB target
- Double gamma: encoding twice (renderer plus sRGB framebuffer or compositor) crushes shadows
- Normal maps and roughness textures wrongly decoded as sRGB, producing lighting errors
- Gradients between saturated colours dip in brightness or look muddy when blended in encoded space
Presets
sRGB-space vs linear-light gradient and checker comparison
{
"colorA": [
1,
0.1,
0.1
],
"colorB": [
0.1,
0.9,
0.2
]
}Show GLSL (28 lines)
// GLSL ES 3.0, Shadertoy-style. Top: red-green blend done in sRGB-encoded vs linear light.
// Bottom: a 50% black/white checker (true 0.5 linear light) next to flat 0.5 encoded and 0.5 linear-encoded patches.
const vec3 A = vec3(1.0, 0.1, 0.1); // sRGB-encoded colour A
const vec3 B = vec3(0.1, 0.9, 0.2); // sRGB-encoded colour B
vec3 toLinear(vec3 c) { return mix(c / 12.92, pow((c + 0.055) / 1.055, vec3(2.4)), step(0.04045, c)); }
vec3 toSRGB(vec3 c) { return mix(c * 12.92, 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, c)); }
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord / iResolution.xy;
vec3 col;
if (uv.y > 0.5) {
float t = uv.x;
vec3 naive = mix(A, B, t); // blended directly on encoded values
vec3 lin = toSRGB(mix(toLinear(A), toLinear(B), t)); // blended in linear light, then encoded
col = (uv.y > 0.75) ? naive : lin;
} else {
float cell = floor(fragCoord.x / 2.0) + floor(fragCoord.y / 2.0);
float checker = mod(cell, 2.0); // physical 50% mix of 0 and 1
float x = uv.x * 3.0;
if (x < 1.0) col = vec3(checker);
else if (x < 2.0) col = vec3(0.5); // encoded 0.5 = only ~21% linear light: too dark
else col = vec3(toSRGB(vec3(0.5)).x); // encoded 0.735 matches the checker's average
}
if (abs(uv.y - 0.5) < 0.004 || abs(uv.y - 0.75) < 0.002) col = vec3(0.0);
fragColor = vec4(col, 1.0);
}
Attribution: written for this index; transfer function is the standard piecewise sRGB curve
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| srgb-vs-linear-blend-comparison | Tesla T4 1920x1080 | 0.88× baseline (feather) · 0.029 ms / 0.030 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| srgb-vs-linear-blend-comparison | NVIDIA L4 1920x1080 | 0.96× baseline (feather) · 0.015 ms / 0.015 ms · 1.9× faster on L4 | opengl-timer-query · Cross-architecture validation |
| srgb-vs-linear-blend-comparison | NVIDIA A100-SXM4-40GB 1920x1080 | 1.00× baseline (feather) · 0.029 ms / 0.029 ms · 1.0× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- AgX: Linear scene radiance from a linear workflow is what the tonemapper compresses into display range before sRGB encoding.
- Dual-filter and progressive-downsample bloom: Bloom downsample and blur chains are only energy-correct when run on linear HDR values.
Sources
- primaryLarry Gritz, Eugene d'Eon. Chapter 24. The Importance of Being Linear. developer.nvidia.com.Verified via live page · 2026-11-29
- implementationmrdoob (2010). mrdoob/three.js. JavaScript 3D Library.GitHub API · license MIT · 2026-11-29