Skip to content

Commit 37763dc

Browse files
authored
WebGPURenderer: Avoid hardcoding color spaces. (#31519)
1 parent 1fffae9 commit 37763dc

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/renderers/common/PostProcessing.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
2+
import { ColorManagement } from '../../math/ColorManagement.js';
23
import { vec4, renderOutput } from '../../nodes/TSL.js';
3-
import { LinearSRGBColorSpace, NoToneMapping } from '../../constants.js';
4+
import { NoToneMapping } from '../../constants.js';
45
import QuadMesh from '../../renderers/common/QuadMesh.js';
56

67
/**
@@ -110,7 +111,7 @@ class PostProcessing {
110111
const outputColorSpace = renderer.outputColorSpace;
111112

112113
renderer.toneMapping = NoToneMapping;
113-
renderer.outputColorSpace = LinearSRGBColorSpace;
114+
renderer.outputColorSpace = ColorManagement.workingColorSpace;
114115

115116
//
116117

@@ -219,7 +220,7 @@ class PostProcessing {
219220
const outputColorSpace = renderer.outputColorSpace;
220221

221222
renderer.toneMapping = NoToneMapping;
222-
renderer.outputColorSpace = LinearSRGBColorSpace;
223+
renderer.outputColorSpace = ColorManagement.workingColorSpace;
223224

224225
//
225226

src/renderers/common/Renderer.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ import XRManager from './XRManager.js';
2121
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
2222

2323
import { Scene } from '../../scenes/Scene.js';
24+
import { ColorManagement } from '../../math/ColorManagement.js';
2425
import { Frustum } from '../../math/Frustum.js';
2526
import { FrustumArray } from '../../math/FrustumArray.js';
2627
import { Matrix4 } from '../../math/Matrix4.js';
2728
import { Vector2 } from '../../math/Vector2.js';
2829
import { Vector4 } from '../../math/Vector4.js';
2930
import { RenderTarget } from '../../core/RenderTarget.js';
30-
import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, LinearSRGBColorSpace, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
31+
import { DoubleSide, BackSide, FrontSide, SRGBColorSpace, NoToneMapping, LinearFilter, HalfFloatType, RGBAFormat, PCFShadowMap } from '../../constants.js';
3132

3233
import { highpModelNormalViewMatrix, highpModelViewMatrix } from '../../nodes/accessors/ModelNode.js';
3334

@@ -1210,7 +1211,7 @@ class Renderer {
12101211
const { currentToneMapping, currentColorSpace } = this;
12111212

12121213
const useToneMapping = currentToneMapping !== NoToneMapping;
1213-
const useColorSpace = currentColorSpace !== LinearSRGBColorSpace;
1214+
const useColorSpace = currentColorSpace !== ColorManagement.workingColorSpace;
12141215

12151216
if ( useToneMapping === false && useColorSpace === false ) return null;
12161217

@@ -1226,7 +1227,7 @@ class Renderer {
12261227
stencilBuffer: stencil,
12271228
type: this._colorBufferType,
12281229
format: RGBAFormat,
1229-
colorSpace: LinearSRGBColorSpace,
1230+
colorSpace: ColorManagement.workingColorSpace,
12301231
generateMipmaps: false,
12311232
minFilter: LinearFilter,
12321233
magFilter: LinearFilter,
@@ -2130,8 +2131,8 @@ class Renderer {
21302131
}
21312132

21322133
/**
2133-
* The current output tone mapping of the renderer. When a render target is set,
2134-
* the output tone mapping is always `NoToneMapping`.
2134+
* The current tone mapping of the renderer. When not producing screen output,
2135+
* the tone mapping is always `NoToneMapping`.
21352136
*
21362137
* @type {number}
21372138
*/
@@ -2142,14 +2143,14 @@ class Renderer {
21422143
}
21432144

21442145
/**
2145-
* The current output color space of the renderer. When a render target is set,
2146-
* the output color space is always `LinearSRGBColorSpace`.
2146+
* The current color space of the renderer. When not producing screen output,
2147+
* the color space is always the working color space.
21472148
*
21482149
* @type {string}
21492150
*/
21502151
get currentColorSpace() {
21512152

2152-
return this.isOutputTarget ? this.outputColorSpace : LinearSRGBColorSpace;
2153+
return this.isOutputTarget ? this.outputColorSpace : ColorManagement.workingColorSpace;
21532154

21542155
}
21552156

0 commit comments

Comments
 (0)