Skip to content

WebGPURenderer: Avoid hardcoding color spaces. #31519

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

Merged
merged 1 commit into from
Jul 28, 2025
Merged

Conversation

Mugen87
Copy link
Collaborator

@Mugen87 Mugen87 commented Jul 28, 2025

Related issue: #29573 (comment)

Description

The PR makes sure that LinearSRGBColorSpace isn't hardcoded as the working color space in WebGPURenderer. As pointed out in #29573 (comment), we should use ColorManagement.workingColorSpace instead.

Copy link

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.39
78.91
338.39
78.91
+0 B
+0 B
WebGPU 566.01
156.49
566.1
156.49
+89 B
+3 B
WebGPU Nodes 564.61
156.25
564.7
156.25
+89 B
+3 B

🌳 Bundle size after tree-shaking

Minimal build including a renderer, camera, empty scene, and dependencies.

Before After Diff
WebGL 469.82
113.62
469.82
113.62
+0 B
+0 B
WebGPU 637.26
172.46
637.32
172.46
+58 B
+3 B
WebGPU Nodes 591.9
161.69
591.96
161.7
+58 B
+3 B

@Mugen87 Mugen87 added this to the r179 milestone Jul 28, 2025
Comment on lines -2145 to 2151
* The current output color space of the renderer. When a render target is set,
* the output color space is always `LinearSRGBColorSpace`.
* The current color space of the renderer. When not producing screen output,
* the color space is always the working color space.
*
* @type {string}
*/
get currentColorSpace() {
Copy link
Collaborator

@donmccurdy donmccurdy Jul 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both the “current color space” and “current output color space” phrasing feel unclear to me, since we're describing output but not necessarily .outputColorSpace — maybe this would be clearer named something like targetColorSpace or dstColorSpace? For example:

/**
 * Target color space of the current render stage. Target is the working color
 * space when a render target is assigned, and the output color space otherwise.
 */
get targetColorSpace() { ... }

Importantly, the only possible results are the working and output color spaces. I didn't mean to imply "render target" with the "target" keyword here, so maybe that's confusing too. 😕

(No changes needed in this PR – just a drive-by thought!)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc @WestLangley just FYI!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The properties should describe what color space and tone mapping the renderer is going to apply during the render pass. It is not necessarily what is defined in outputColorSpace and toneMapping. So maybe the term "target" is more clear?

@Mugen87 Mugen87 merged commit 37763dc into mrdoob:dev Jul 28, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants