|
@@ -3,6 +3,7 @@ import { WebGLShader } from './WebGLShader.js';
|
|
|
import { ShaderChunk } from '../shaders/ShaderChunk.js';
|
|
|
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, AgXToneMapping, ACESFilmicToneMapping, NeutralToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace, LinearDisplayP3ColorSpace, DisplayP3ColorSpace, P3Primaries, Rec709Primaries } from '../../constants.js';
|
|
|
import { ColorManagement } from '../../math/ColorManagement.js';
|
|
|
+import { Vector3 } from '../../math/Vector3.js';
|
|
|
|
|
|
// From https://www.khronos.org/registry/webgl/extensions/KHR_parallel_shader_compile/
|
|
|
const COMPLETION_STATUS_KHR = 0x91B1;
|
|
@@ -142,6 +143,30 @@ function getToneMappingFunction( functionName, toneMapping ) {
|
|
|
|
|
|
}
|
|
|
|
|
|
+const _v0 = /*@__PURE__*/ new Vector3();
|
|
|
+
|
|
|
+function getLuminanceFunction() {
|
|
|
+
|
|
|
+ ColorManagement.getLuminanceCoefficients( _v0 );
|
|
|
+
|
|
|
+ const r = _v0.x.toFixed( 4 );
|
|
|
+ const g = _v0.y.toFixed( 4 );
|
|
|
+ const b = _v0.z.toFixed( 4 );
|
|
|
+
|
|
|
+ return [
|
|
|
+
|
|
|
+ 'float luminance( const in vec3 rgb ) {',
|
|
|
+
|
|
|
+ ` const vec3 weights = vec3( ${ r }, ${ g }, ${ b } );`,
|
|
|
+
|
|
|
+ ' return dot( weights, rgb );',
|
|
|
+
|
|
|
+ '}'
|
|
|
+
|
|
|
+ ].join( '\n' );
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
function generateVertexExtensions( parameters ) {
|
|
|
|
|
|
const chunks = [
|
|
@@ -811,6 +836,7 @@ function WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {
|
|
|
|
|
|
ShaderChunk[ 'colorspace_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below
|
|
|
getTexelEncodingFunction( 'linearToOutputTexel', parameters.outputColorSpace ),
|
|
|
+ getLuminanceFunction(),
|
|
|
|
|
|
parameters.useDepthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',
|
|
|
|