(function (global, factory) { if (typeof define === "function" && define.amd) { define(["exports"], factory); } else if (typeof exports !== "undefined") { factory(exports); } else { var mod = { exports: {} }; factory(mod.exports); global.ACESFilmicToneMappingShader = mod.exports; } })(typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : this, function (_exports) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); _exports.ACESFilmicToneMappingShader = void 0; /** * ACES Filmic Tone Mapping Shader by Stephen Hill * source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs * * this implementation of ACES is modified to accommodate a brighter viewing environment. * the scale factor of 1/0.6 is subjective. see discussion in #19621. */ var ACESFilmicToneMappingShader = { uniforms: { 'tDiffuse': { value: null }, 'exposure': { value: 1.0 } }, vertexShader: /* glsl */ "\n\n\t\tvarying vec2 vUv;\n\n\t\tvoid main() {\n\n\t\t\tvUv = uv;\n\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\n\t\t}", fragmentShader: /* glsl */ "\n\n\t\t#define saturate(a) clamp( a, 0.0, 1.0 )\n\n\t\tuniform sampler2D tDiffuse;\n\n\t\tuniform float exposure;\n\n\t\tvarying vec2 vUv;\n\n\t\tvec3 RRTAndODTFit( vec3 v ) {\n\n\t\t\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\t\t\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\t\t\treturn a / b;\n\n\t\t}\n\n\t\tvec3 ACESFilmicToneMapping( vec3 color ) {\n\n\t\t// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT\n\t\t\tconst mat3 ACESInputMat = mat3(\n\t\t\t\tvec3( 0.59719, 0.07600, 0.02840 ), // transposed from source\n\t\t\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\t\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t\t\t);\n\n\t\t// ODT_SAT => XYZ => D60_2_D65 => sRGB\n\t\t\tconst mat3 ACESOutputMat = mat3(\n\t\t\t\tvec3( 1.60475, -0.10208, -0.00327 ), // transposed from source\n\t\t\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\t\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t\t\t);\n\n\t\t\tcolor = ACESInputMat * color;\n\n\t\t// Apply RRT and ODT\n\t\t\tcolor = RRTAndODTFit( color );\n\n\t\t\tcolor = ACESOutputMat * color;\n\n\t\t// Clamp to [0, 1]\n\t\t\treturn saturate( color );\n\n\t\t}\n\n\t\tvoid main() {\n\n\t\t\tvec4 tex = texture2D( tDiffuse, vUv );\n\n\t\t\ttex.rgb *= exposure / 0.6; // pre-exposed, outside of the tone mapping function\n\n\t\t\tgl_FragColor = vec4( ACESFilmicToneMapping( tex.rgb ), tex.a );\n\n\t\t}" }; _exports.ACESFilmicToneMappingShader = ACESFilmicToneMappingShader; });