Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGLRenderer: Add Support for Khronos Neutral Tone Mapping #27668

Merged
merged 7 commits into from
Feb 9, 2024
Prev Previous commit
Next Next commit
rename
  • Loading branch information
elalish committed Feb 7, 2024
commit 1bb57cadca98ec4540ea0e84348b912e7f70f15e
4 changes: 2 additions & 2 deletions examples/jsm/postprocessing/OutputPass.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
CineonToneMapping,
AgXToneMapping,
ACESFilmicToneMapping,
CommerceToneMapping,
KhronosNeutralToneMapping,
SRGBTransfer
} from 'three';
import { Pass, FullScreenQuad } from './Pass.js';
Expand Down Expand Up @@ -62,7 +62,7 @@ class OutputPass extends Pass {
else if ( this._toneMapping === CineonToneMapping ) this.material.defines.CINEON_TONE_MAPPING = '';
else if ( this._toneMapping === ACESFilmicToneMapping ) this.material.defines.ACES_FILMIC_TONE_MAPPING = '';
else if ( this._toneMapping === AgXToneMapping ) this.material.defines.AGX_TONE_MAPPING = '';
else if ( this._toneMapping === CommerceToneMapping ) this.material.defines.COMMERECE_TONE_MAPPING = '';
else if ( this._toneMapping === KhronosNeutralToneMapping ) this.material.defines.COMMERECE_TONE_MAPPING = '';

this.material.needsUpdate = true;

Expand Down
2 changes: 1 addition & 1 deletion examples/jsm/shaders/OutputShader.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const OutputShader = {

#elif defined( COMMERECE_TONE_MAPPING )

gl_FragColor.rgb = CommerceToneMapping( gl_FragColor.rgb );
gl_FragColor.rgb = KhronosNeutralToneMapping( gl_FragColor.rgb );

#endif

Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const CineonToneMapping = 3;
export const ACESFilmicToneMapping = 4;
export const CustomToneMapping = 5;
export const AgXToneMapping = 6;
export const CommerceToneMapping = 7;
export const KhronosNeutralToneMapping = 7;
export const AttachedBindMode = 'attached';
export const DetachedBindMode = 'detached';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ vec3 AgXToneMapping( vec3 color ) {

// https://modelviewer.dev/examples/tone-mapping

vec3 CommerceToneMapping( vec3 color ) {
vec3 KhronosNeutralToneMapping( vec3 color ) {
float startCompression = 0.8 - 0.04;
float desaturation = 0.15;

Expand Down
6 changes: 3 additions & 3 deletions src/renderers/webgl/WebGLProgram.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { WebGLUniforms } from './WebGLUniforms.js';
import { WebGLShader } from './WebGLShader.js';
import { ShaderChunk } from '../shaders/ShaderChunk.js';
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, AgXToneMapping, ACESFilmicToneMapping, CommerceToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace, LinearDisplayP3ColorSpace, DisplayP3ColorSpace, P3Primaries, Rec709Primaries } from '../../constants.js';
import { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, CubeRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, AgXToneMapping, ACESFilmicToneMapping, KhronosNeutralToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GLSL3, LinearSRGBColorSpace, SRGBColorSpace, LinearDisplayP3ColorSpace, DisplayP3ColorSpace, P3Primaries, Rec709Primaries } from '../../constants.js';
import { ColorManagement } from '../../math/ColorManagement.js';

// From https://www.khronos.org/registry/webgl/extensions/KHR_parallel_shader_compile/
Expand Down Expand Up @@ -124,8 +124,8 @@ function getToneMappingFunction( functionName, toneMapping ) {
toneMappingName = 'AgX';
break;

case CommerceToneMapping:
toneMappingName = 'Commerce';
case KhronosNeutralToneMapping:
toneMappingName = 'KhronosNeutral';
break;

case CustomToneMapping:
Expand Down
2 changes: 1 addition & 1 deletion test/unit/src/constants.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default QUnit.module( 'Constants', () => {
assert.equal( Constants.ACESFilmicToneMapping, 4, 'ACESFilmicToneMapping is equal to 4' );
assert.equal( Constants.CustomToneMapping, 5, 'CustomToneMapping is equal to 5' );
assert.equal( Constants.AgXToneMapping, 6, 'AgXToneMapping is equal to 6' );
assert.equal( Constants.CommerceToneMapping, 7, 'CommerceToneMapping is equal to 7' );
assert.equal( Constants.KhronosNeutralToneMapping, 7, 'KhronosNeutralToneMapping is equal to 7' );

assert.equal( Constants.AttachedBindMode, 'attached', 'AttachedBindMode is equal to attached' );
assert.equal( Constants.DetachedBindMode, 'detached', 'DetachedBindMode is equal to detached' );
Expand Down