UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

21 lines (20 loc) 897 B
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{glsl as o}from"../core/shaderModules/glsl.js";function e(e){e.code.add(o`vec3 tonemapACES(vec3 x) { return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0); }`),e.code.add(o`vec3 tonemapKhronosNeutral(vec3 color, float exposure) { const float startCompression = 0.76; const float desaturation = 0.15; color *= exposure; float x = min( color.r, min( color.g, color.b ) ); float offset = x < 0.08 ? x - 6.25 * x * x : 0.04; color -= offset; float peak = max( color.r, max( color.g, color.b ) ); if ( peak < startCompression ) { return color; } float d = 1.0 - startCompression; float newPeak = 1.0 - d * d / ( peak + d - startCompression ); color *= newPeak / peak; float g = 1.0 - 1.0 / ( desaturation * ( peak - newPeak ) + 1.0 ); return mix( color, vec3( newPeak ), g ); }`)}export{e as ToneMapping};