export default /* glsl */` #ifndef saturate // may have defined saturate() already #define saturate(a) clamp( a, 0.0, 1.0 ) #endif uniform float toneMappingExposure; uniform float toneMappingWhitePoint; // exposure only vec3 LinearToneMapping( vec3 color ) { return toneMappingExposure * color; } // source: https://www.cs.utah.edu/~reinhard/cdrom/ vec3 ReinhardToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( color / ( vec3( 1.0 ) + color ) ); } // source: http://filmicgames.com/archives/75 #define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) ) vec3 Uncharted2ToneMapping( vec3 color ) { // John Hable's filmic operator from Uncharted 2 video game color *= toneMappingExposure; return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) ); } // source: http://filmicgames.com/archives/75 vec3 OptimizedCineonToneMapping( vec3 color ) { // optimized filmic operator by Jim Hejl and Richard Burgess-Dawson color *= toneMappingExposure; color = max( vec3( 0.0 ), color - 0.004 ); return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) ); } // source: https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ vec3 ACESFilmicToneMapping( vec3 color ) { color *= toneMappingExposure; return saturate( ( color * ( 2.51 * color + 0.03 ) ) / ( color * ( 2.43 * color + 0.59 ) + 0.14 ) ); } `;