Skip to content

WebGPURenderer: Add warning when video textures with invalid color spaces are used. #31569

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 3 commits into from
Aug 6, 2025

Conversation

ycw
Copy link
Contributor

@ycw ycw commented Aug 4, 2025

This PR continues the work from #31534

Copy link

github-actions bot commented Aug 4, 2025

📦 Bundle size

Full ESM build, minified and gzipped.

Before After Diff
WebGL 338.63
79.03
338.63
79.03
+0 B
+0 B
WebGPU 567.59
157
567.59
157
+0 B
+0 B
WebGPU Nodes 566.2
156.75
566.2
156.75
+0 B
+0 B

🌳 Bundle size after tree-shaking

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

Before After Diff
WebGL 470.38
113.78
470.38
113.78
+0 B
+0 B
WebGPU 639.34
173.06
639.34
173.06
+0 B
+0 B
WebGPU Nodes 593.98
162.33
593.98
162.33
+0 B
+0 B

@sunag sunag added this to the r180 milestone Aug 4, 2025

if ( texture.isVideoTexture && texture.colorSpace !== SRGBColorSpace ) {

console.warn( 'Textures: VideoTexture is rarely used with non-SRGB color space.' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

How about:

console.warn( 'WebGPURenderer: VideoTexture must be used with sRGB color space.' );

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would we not allow putting data into a video, annotated with NoColorSpace?

Copy link
Collaborator

@Mugen87 Mugen87 Aug 5, 2025

Choose a reason for hiding this comment

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

Not with the current implementation. The copy of video data uses copyExternalImageToTexture() and that method only support sRGB and Display-P3 data. See related PR #31416.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see! Ok, good to know. Hopefully something we can loosen later, but no objection to the warning in the meantime.


if ( texture.isVideoTexture && texture.colorSpace !== SRGBColorSpace ) {

console.warn( 'Textures: VideoTexture is rarely used with non-SRGB color space.' );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would we not allow putting data into a video, annotated with NoColorSpace?

@@ -326,6 +326,14 @@ class Textures extends DataMap {

this.info.memory.textures ++;

//

if ( texture.isVideoTexture && texture.colorSpace !== SRGBColorSpace ) {
Copy link
Collaborator

@donmccurdy donmccurdy Aug 5, 2025

Choose a reason for hiding this comment

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

I think you may want to check for the sRGB transfer functions, not color space. For example Display P3 uses sRGB transfer functions, and should work fine. Example:

Suggested change
if ( texture.isVideoTexture && texture.colorSpace !== SRGBColorSpace ) {
if ( texture.isVideoTexture && ColorManagement.getTransfer( texture.colorSpace ) !== SRGBTransfer ) {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would we not allow putting data into a video, annotated with NoColorSpace?

I initially considered this use case, so the warning only mentioned rare scenarios...

ycw and others added 2 commits August 6, 2025 10:40
@Mugen87 Mugen87 merged commit bc1c2bb into mrdoob:dev Aug 6, 2025
7 of 8 checks passed
@Mugen87 Mugen87 changed the title Warns for VideoTexture with non-srgb color spaces WebGPURenderer: Add warning when video textures with invalid color spaces are used. Aug 6, 2025
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