---
id: "linear-color-workflow"
title: "Linear-space rendering and gamma correction"
aliases: [linear workflow, gamma-correct rendering, sRGB framebuffer, linear light]
domain: "post"
stage: "post"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, blender, unity, unreal, godot]
year_introduced: 2007
inputs: [texture, hdr-image]
outputs: [ldr-image]
style: "both"
dynamic: "both"
cost: "cheap"
authority: "Gritz & d'Eon"
url: "https://texelatlas.vercel.app/t/linear-color-workflow/"
sources_verified_at: "2026-11-29"
---
# Linear-space rendering and gamma correction (Gritz & d'Eon)

> 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.

## 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

## 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](https://texelatlas.vercel.app/t/agx-tonemapping.md), [Khronos PBR Neutral tone mapper](https://texelatlas.vercel.app/t/khronos-pbr-neutral.md)) 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 use it

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](https://texelatlas.vercel.app/t/ggx-trowbridge-reitz.md)-style PBR to look right. Add [3D LUT color grading](https://texelatlas.vercel.app/t/lut-color-grading.md) and a tonemapper after it rather than instead of it. Choose a wider working gamut and [HDR display output (PQ / BT.2100)](https://texelatlas.vercel.app/t/hdr-display-output-pq.md) only when targeting HDR panels; [Oklab perceptual color space](https://texelatlas.vercel.app/t/oklab.md) is the space for perceptual operations such as gradients, not for light transport.

## Cost

cheap — Free with sRGB texture and framebuffer formats on modern GPUs; manual encode/decode is a few ALU instructions per pixel.
Measured GPU Weight: 0.88× baseline (feather) — 0.0291 ms median / 0.0299 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 0.96× baseline (feather) — 0.0152 ms median (1.91× faster on L4).
Ampere A100 scaling: 1× baseline (feather) — 0.0288 ms median (1.01× faster on A100).

## Failure modes

- 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

## Engine support

- babylonjs: builtin — `PBRMaterial shades in linear space with automatic sRGB-to-linear texture conversion` (evidence: https://github.com/BabylonJS/Babylon.js/blob/9.38.0/packages/dev/core/src/Materials/PBR/pbrBaseMaterial.ts, checked 2026-12-01)
- blender: builtin — `Render Properties > Color Management (scene-linear working space)` (evidence: https://docs.blender.org/manual/en/5.2/render/color_management/color_spaces.html, checked 2026-12-01)
- godot: builtin — `Forward+ and Mobile renderers shade in linear HDR; sRGB textures decode automatically` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/BaseMaterial3D.xml, checked 2026-12-01)
- metal: builtin — `MTLPixelFormat.rgba8Unorm_srgb / bgra8Unorm_srgb (hardware sRGB decode/encode)` (evidence: https://developer.apple.com/tutorials/data/documentation/metal/mtlpixelformat.json, checked 2026-12-01)
- threejs: builtin — `THREE.ColorManagement.enabled; renderer.outputColorSpace = THREE.SRGBColorSpace` (evidence: https://github.com/mrdoob/three.js/blob/r187/src/math/ColorManagement.js, checked 2026-12-01)
- unity: builtin — `Project Settings > Player > Other Settings > Color Space = Linear` (evidence: https://docs.unity3d.com/6000.0/Documentation/ScriptReference/ColorSpace.Linear.html, checked 2026-12-01)
- unreal: builtin — `Project Settings > Rendering > Working Color Space (linear HDR rendering with sRGB and OpenColorIO transforms)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/color-management-with-opencolorio-in-unreal-engine, checked 2026-12-01)
- webgpu: builtin — `Texture formats rgba8unorm-srgb / bgra8unorm-srgb (hardware sRGB decode/encode)` (evidence: https://www.w3.org/TR/webgpu/, checked 2026-12-01)

## Dataflow

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

## Presets

### sRGB-space vs linear-light gradient and checker comparison (glsl-fragment; rendered 2026-11-29)

```json
{
  "colorA": [
    1,
    0.1,
    0.1
  ],
  "colorB": [
    0.1,
    0.9,
    0.2
  ]
}
```

```glsl
// 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

## Lineage

- extended by [HDR display output (PQ / BT.2100)](https://texelatlas.vercel.app/t/hdr-display-output-pq.md)

## Combines with

- [AgX](https://texelatlas.vercel.app/t/agx-tonemapping.md): Linear scene radiance from a linear workflow is what the tonemapper compresses into display range before sRGB encoding.
- [Dual-filter and progressive-downsample bloom](https://texelatlas.vercel.app/t/dual-filter-bloom.md): Bloom downsample and blur chains are only energy-correct when run on linear HDR values.

## Sources

1. [primary] Larry Gritz, Eugene d'Eon Chapter 24. The Importance of Being Linear. developer.nvidia.com. https://developer.nvidia.com/gpugems/gpugems3/part-iv-image-effects/chapter-24-importance-being-linear (verified via http on 2026-11-29)
2. [implementation] mrdoob (2010) mrdoob/three.js. https://github.com/mrdoob/three.js License: MIT. (verified via github on 2026-11-29)

## Cite this entry

Texel. "Linear-space rendering and gamma correction." https://texelatlas.vercel.app/t/linear-color-workflow/ (accessed 2026-12-01).
