glsl-tone-map

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


Keywords
glsl, tonemap, tonemapping, tone, agx, neutral, aces, uncharted, filmic, lottes, reinhard, reinhard2, uchimura, unreal, filmic-tone-mapping, tone-mapping
License
MIT
Install
npm install glsl-tone-map@2.0.1

Documentation

glsl-tone-map

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

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

paypal coinbase twitter

Installation

npm install glsl-tone-map

Usage

ESM

import * as glslToneMap from "glsl-tone-map";

const shader = /* glsl */ `
${glslToneMap.AGX}
${glslToneMap.NEUTRAL}
${glslToneMap.ACES}
${glslToneMap.FILMIC}
${glslToneMap.LOTTES}
${glslToneMap.REINHARD}
${glslToneMap.REINHARD2}
${glslToneMap.UCHIMURA}
${glslToneMap.UNCHARTED2}
${glslToneMap.UNREAL}

void main() {
  // ...
  color.rgb = agx(color.rgb);
  color.rgb = neutral(color.rgb);
  color.rgb = aces(color.rgb);
  color.rgb = filmic(color.rgb);
  color.rgb = lottes(color.rgb);
  color.rgb = reinhard(color.rgb);
  color.rgb = reinhard2(color.rgb);
  color.rgb = uchimura(color.rgb);
  color.rgb = uncharted2(color.rgb);
  color.rgb = unreal(color.rgb);
}`;

glslify

#pragma glslify: agx = require(glsl-tone-map/agx)
#pragma glslify: neutral = require(glsl-tone-map/neutral)
#pragma glslify: aces = require(glsl-tone-map/aces)
#pragma glslify: filmic = require(glsl-tone-map/filmic)
#pragma glslify: lottes = require(glsl-tone-map/lottes)
#pragma glslify: reinhard = require(glsl-tone-map/reinhard)
#pragma glslify: reinhard2 = require(glsl-tone-map/reinhard2)
#pragma glslify: uchimura = require(glsl-tone-map/uchimura)
#pragma glslify: uncharted2 = require(glsl-tone-map/uncharted2)
#pragma glslify: unreal = require(glsl-tone-map/unreal)

void main() {
  // ...
  color.rgb = agx(color.rgb);
  color.rgb = neutral(color.rgb);
  color.rgb = aces(color.rgb);
  color.rgb = filmic(color.rgb);
  color.rgb = lottes(color.rgb);
  color.rgb = reinhard(color.rgb);
  color.rgb = reinhard2(color.rgb);
  color.rgb = uchimura(color.rgb);
  color.rgb = uncharted2(color.rgb);
  color.rgb = unreal(color.rgb);
}

License

MIT. See license file.