Skip to content

Repository files navigation

shaders-tone-map

Conventional Commits styled with prettier linted with eslint license

Thirteen tone mapping operators for GLSL and WGSL, as ES module strings and as plain shader files. The two ports are one to one, so both languages give you the same curves.

Response curves for the thirteen tone mapping operators, linear input against linear output

Packages

Package Install For
glsl-tone-map npm npm i glsl-tone-map WebGL, glslify
wgsl-tone-map npm npm i wgsl-tone-map WebGPU

Usage

Every operator is a string you interpolate into your shader:

import { AGX } from "glsl-tone-map";

const fragmentShader = /* glsl */ `
${AGX}

void main() {
  gl_FragColor = vec4(agx(color.rgb), 1.0);
}`;

Each one also ships as a plain file — glsl-tone-map/agx.glsl for glslify or a raw-text bundler import, wgsl-tone-map/agx.wgsl likewise.

Operators

Operator Reference
aces Narkowicz 2015, "ACES Filmic Tone Mapping Curve"
acesHill Stephen Hill's fit of the full ACES RRT and ODT, via BakingLab
agx Missing Deadlines, Filament and AgX_LUT_Gen. Also agxGolden, agxPunchy, agxNeedle
filmic Hejl and Burgess-Dawson, via Filmic Tonemapping Operators
hejl Jim Hejl 2015, ToneMapFilmic_Hejl2015
lottes Lottes 2016, "Advanced Techniques and Optimization of HDR Color Pipelines"
neutral Khronos PBR Neutral Tone Mapper
reinhard, reinhard2 Reinhard et al. 2002, the second with a white point
reinhardJodie Reinhard driven by luminance so hue survives, via Tone Mapping
uchimura Uchimura 2017, "HDR theory and practice" (curve)
uncharted2 Hable, Uncharted 2
unreal Unreal 3 documentation, "Color Grading"

Collected from this comparison of tone mapping operators and this Shadertoy.

Notes

Color space. Every operator takes and returns linear color, with one exception: unreal has gamma 2.2 baked in, so don't apply an sRGB transform after it.

Range. aces, acesHill, agx, filmic, neutral, reinhard and uchimura stay within [0, 1]. hejl, lottes, reinhard2, uncharted2 and unreal can exceed 1.0 above their white point, and reinhardJodie can on saturated colors — clamp if your target needs it.

WGSL. It has no function overloading, so the f32 variants are suffixed with Scalar (acesScalar) and the parameterised curves are named hejlCurve, uchimuraCurve and uncharted2Curve. Everything else matches the GLSL sources.

License

MIT. See license file.

About

A collection of tone mapping functions available both as ES modules strings and as GLSL files for use with glslify.

Topics

Resources

Code of conduct

Contributing

Stars

235 stars

Watchers

5 watching

Forks

Releases

Packages

Used by

Contributors

Languages