diff --git a/examples/jsm/postprocessing/OutputPass.js b/examples/jsm/postprocessing/OutputPass.js index d2207624d9ed95..09e36614b25325 100644 --- a/examples/jsm/postprocessing/OutputPass.js +++ b/examples/jsm/postprocessing/OutputPass.js @@ -1,11 +1,12 @@ import { + ColorManagement, RawShaderMaterial, UniformsUtils, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, - SRGBColorSpace + SRGBTransfer } from 'three'; import { Pass, FullScreenQuad } from './Pass.js'; import { OutputShader } from '../shaders/OutputShader.js'; @@ -51,7 +52,7 @@ class OutputPass extends Pass { this.material.defines = {}; - if ( this._outputColorSpace == SRGBColorSpace ) this.material.defines.SRGB_COLOR_SPACE = ''; + if ( ColorManagement.getTransfer( this._outputColorSpace ) === SRGBTransfer ) this.material.defines.SRGB_TRANSFER = ''; if ( this._toneMapping === LinearToneMapping ) this.material.defines.LINEAR_TONE_MAPPING = ''; else if ( this._toneMapping === ReinhardToneMapping ) this.material.defines.REINHARD_TONE_MAPPING = ''; diff --git a/examples/jsm/shaders/OutputShader.js b/examples/jsm/shaders/OutputShader.js index d15c4dd143aef8..cf7a18ae7f9de8 100644 --- a/examples/jsm/shaders/OutputShader.js +++ b/examples/jsm/shaders/OutputShader.js @@ -65,9 +65,9 @@ const OutputShader = { // color space - #ifdef SRGB_COLOR_SPACE + #ifdef SRGB_TRANSFER - gl_FragColor = LinearTosRGB( gl_FragColor ); + gl_FragColor = sRGBTransferOETF( gl_FragColor ); #endif diff --git a/examples/webgl_test_wide_gamut.html b/examples/webgl_test_wide_gamut.html index e480c840c71574..1959f45690b336 100644 --- a/examples/webgl_test_wide_gamut.html +++ b/examples/webgl_test_wide_gamut.html @@ -69,7 +69,6 @@ import * as THREE from 'three'; - import WebGL from 'three/addons/capabilities/WebGL.js'; import { GUI } from 'three/addons/libs/lil-gui.module.min.js'; let container, camera, renderer, loader; diff --git a/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js b/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js index 357750b76016fc..fa35caeab28dc2 100644 --- a/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +++ b/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js @@ -2,17 +2,17 @@ export default /* glsl */` // http://www.russellcottrell.com/photo/matrixCalculator.htm -mat3 REC709_TO_P3 = transpose( mat3( - 0.8224621, 0.0331941, 0.0170827, - 0.1775380, 0.9668058, 0.0723974, - -0.0000001, 0.0000001, 0.9105199 -) ); +const mat3 REC709_TO_P3 = mat3( + 0.8224621, 0.177538, - 0.0000001, + 0.0331941, 0.9668058, 0.0000001, + 0.0170827, 0.0723974, 0.9105199 +); -mat3 P3_TO_REC709 = transpose( mat3( - 1.2249401, - 0.0420569, - 0.0196376, - - 0.2249404, 1.0420571, - 0.0786361, - 0.0000001, 0.0000000, 1.0982735 -) ); +const mat3 P3_TO_REC709 = mat3( + 1.2249401, - 0.2249404, 0.0000001, + - 0.0420569, 1.0420571, 0.0000000, + - 0.0196376, - 0.0786361, 1.0982735 +); vec4 Rec709ToP3( in vec4 value ) { return vec4( value.rgb * REC709_TO_P3, value.a );