Skip to content

Conversation

ycw
Copy link
Contributor

@ycw ycw commented Jul 30, 2025

Related: #31416, Discussion: #31533

Due to inherent design constraints in WebGPURenderer, VideoTexture#colorSpace must be explicitly set to SRGBColorSpace. Assigning alternative values may result in perceptible color inaccuracies, including luminance shifts and hue distortion. This outcome is a direct consequence of the renderer's internal texture handling mechanisms (i.e. copyExternalImageToTexture with destination.colorSpace:'srgb') and is entirely independent of the color space employed by the browser during video decoding.

@ycw ycw changed the title VideoTexture: Explicitly set colorSpace to SRGBColorSpace for the new apporach Explicitly set VideoTexture#colorSpace to SRGBColorSpace Jul 30, 2025
Copy link

github-actions bot commented Jul 30, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.82
79.08
338.82
79.08
+0 B
+0 B
WebGPU 566.16
156.5
566.16
156.5
+0 B
+0 B
WebGPU Nodes 564.77
156.26
564.77
156.26
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 470.25
113.78
470.25
113.78
+0 B
+0 B
WebGPU 637.38
172.47
637.38
172.47
+0 B
+0 B
WebGPU Nodes 592.02
161.71
592.02
161.71
+0 B
+0 B

@sunag sunag merged commit 10a2144 into mrdoob:dev Jul 31, 2025
9 checks passed
@mrdoob mrdoob added this to the r179 milestone Aug 1, 2025
@mrdoob
Copy link
Owner

mrdoob commented Aug 1, 2025

Due to inherent design constraints in WebGPURenderer, VideoTexture#colorSpace must be explicitly set to SRGBColorSpace.

@sunag @Mugen87 If that's the case, shouldn't the renderer set this automatically? Maybe warning the user once that colorSpace was changed?

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 2, 2025

Yes, a warning that informs about an invalid color space is surely helpful.

@Mugen87
Copy link
Collaborator

Mugen87 commented Aug 2, 2025

@ycw Are you interested in giving this a try? A possible place for a check is below when the texture is initialized for the first time:

if ( textureData.initialized !== true ) {
textureData.initialized = true;
textureData.generation = texture.version;

Although @sunag might recommend an alternative place.

@sunag
Copy link
Collaborator

sunag commented Aug 2, 2025

Although @sunag might recommend an alternative place.

If the idea is to align with both backends it would be a good place.

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.

4 participants