---
id: "agx-tonemapping"
title: "AgX"
domain: "post"
stage: "post"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, mobile-gpu, blender]
year_introduced: 2022
inputs: [hdr-image]
outputs: [ldr-image]
style: "photoreal"
dynamic: "both"
cost: "cheap"
authority: "sobotka, 2022"
url: "https://texelatlas.vercel.app/t/agx-tonemapping/"
sources_verified_at: "2026-11-29"
---
# AgX (sobotka, 2022)

> A display transform by Troy Sobotka that maps scene-referred values through a log encoding and sigmoid in a rotated primaries space. Highlights roll off to white without hue skews or ACES-style saturation.

## Reach for it when

- bright saturated lights turn orange or cyan at highlights
- highlights shift hue instead of rolling off to white
- want a neutral camera-like look for hdr renders
- emissive colours look garish after tone mapping

## How it works

AgX first applies an inset matrix that moves colours slightly toward the neutral axis so extreme values can desaturate gracefully. The result is encoded as log2 between a fixed black and white relative exposure (about minus 12 to plus 4 stops) and normalised, then a sigmoid, fitted as a polynomial, applies the contrast curve. An outset matrix restores most chroma, and an optional look adds slope, power and saturation tweaks for punchier or flatter results. The shaders in Blender and three.js are small enough to run per fragment. The result reaches white with an even desaturation, so a bright blue light does not flip to purple.

## When to use it

Choose it when you want predictable, neutral highlights and a camera-like rendering, especially for saturated emissive content.

Prefer [ACES filmic tonemapping](https://texelatlas.vercel.app/t/aces-tonemapping.md) when you need ACES compatibility and the punchy look. Prefer [Khronos PBR Neutral tone mapper](https://texelatlas.vercel.app/t/khronos-pbr-neutral.md) for product viewers where albedo colours must not shift.

## Cost

cheap — Two matrix multiplies and a polynomial per pixel.
Measured GPU Weight: 1.18× baseline (feather) — 0.0387 ms median / 0.0411 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 1× baseline (feather) — 0.0159 ms median (2.43× faster on L4).
Ampere A100 scaling: 1× baseline (feather) — 0.0288 ms median (1.34× faster on A100).

## Failure modes

- Flat, low-contrast default look unless a contrast look is chosen
- Slightly desaturated mid-tones compared with ACES or Neutral
- Several incompatible implementations (Blender, three.js, Filament) differ in constants
- Fully saturated primaries cannot reach display boundaries because of the inset

## Engine support

- blender: builtin — `Properties > Render > Color Management > View Transform = AgX` (evidence: https://docs.blender.org/manual/en/5.2/render/color_management/displays_views.html, checked 2026-12-01)
- godot: builtin — `Environment.tonemap_mode = Environment.TONE_MAPPER_AGX` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/Environment.xml, checked 2026-12-01)
- threejs: builtin — `renderer.toneMapping = THREE.AgXToneMapping` (evidence: https://github.com/mrdoob/three.js/blob/r187/src/constants.js, checked 2026-12-01)

## Dataflow

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

## Presets

### three.js AgX tone mapping, exposure 1.0 (three-tonemap; rendered 2026-11-29)

```json
{
  "toneMapping": "AgX",
  "exposure": 1
}
```

Attribution: written for this index

### AgX inset-matrix HDR tonemapper (WGSL) (webgpu-wgsl; WebGPU WGSL runtime)

```json
{
  "EXPOSURE": 1,
  "PUNCH": 1.15
}
```

```wgsl
// WebGPU WGSL fragment specimen: AgX log-encoding + sigmoid look curve
const EXPOSURE: f32 = 1.0000; // P
const PUNCH: f32 = 1.1500; // P

fn agx_map(x_in: vec3f) -> vec3f {
  let m = mat3x3f(
    vec3f(0.842479, 0.042328, 0.042376),
    vec3f(0.078434, 0.878469, 0.078434),
    vec3f(0.079224, 0.079166, 0.879143)
  );
  let x = max(m * max(x_in * EXPOSURE, vec3f(1e-5)), vec3f(1e-5));
  let lv = clamp((log2(x) + 12.47393) / 16.5, vec3f(0.0), vec3f(1.0));
  let s = lv * lv * (3.0 - 2.0 * lv);
  return pow(clamp(s, vec3f(0.0), vec3f(1.0)), vec3f(PUNCH));
}

@fragment
fn fs_main(@builtin(position) pos: vec4f) -> @location(0) vec4f {
  let uv = (pos.xy - 0.5 * u.resolution) / u.resolution.y;
  var col = vec3f(0.05, 0.055, 0.065);
  var hues = array<vec3f, 5>(
    vec3f(1.0, 0.22, 0.12),
    vec3f(1.0, 0.76, 0.12),
    vec3f(0.18, 0.82, 0.42),
    vec3f(0.12, 0.54, 1.0),
    vec3f(0.70, 0.30, 1.0)
  );
  for (var i: i32 = 0; i < 5; i = i + 1) {
    let c = vec2f((f32(i) - 2.0) * 0.30, -0.06);
    let d = uv - c;
    let r2 = dot(d, d);
    if (r2 < 0.018) {
      let n = normalize(vec3f(d.x, -d.y, sqrt(0.018 - r2)));
      let l = max(dot(n, normalize(vec3f(0.4, 0.6, 0.7))), 0.12);
      col = hues[i] * (l * 0.75 + pow(2.0, f32(i) - 0.4));
    }
  }
  if (uv.y > 0.20 && uv.y < 0.34 && abs(uv.x) < 0.72) {
    let ev = mix(-3.0, 5.0, (uv.x + 0.72) / 1.44);
    col = vec3f(pow(2.0, ev));
  }
  return vec4f(agx_map(col), 1.0);
}
```

Attribution: written for this index

## Lineage

- extends [ACES filmic tonemapping](https://texelatlas.vercel.app/t/aces-tonemapping.md)

## Combines with

- [Auto exposure from luminance histogram](https://texelatlas.vercel.app/t/auto-exposure-histogram.md): Exposure feeds the log encoding range.
- [3D LUT color grading](https://texelatlas.vercel.app/t/lut-color-grading.md): AgX is commonly followed by a LUT-based look.

## Sources

1. [primary] sobotka (2022) sobotka/AgX. https://github.com/sobotka/AgX (verified via github 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. "AgX." https://texelatlas.vercel.app/t/agx-tonemapping/ (accessed 2026-12-01).
