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

VideoTexture’s colorSpace not working on Emissive channel #29625

Closed
vis-prime opened this issue Oct 11, 2024 · 4 comments · Fixed by #29657
Closed

VideoTexture’s colorSpace not working on Emissive channel #29625

vis-prime opened this issue Oct 11, 2024 · 4 comments · Fixed by #29657
Milestone

Comments

@vis-prime
Copy link
Contributor

vis-prime commented Oct 11, 2024

Description

When a videoTexture is applied on emissiveMap of a MeshStandardMaterial , SRGBColorSpace does not work and it always stays in Linear Color Space.

Reproduction steps

  • create videoTexture
  • set its colorspace to SRGBColorSpace
  • Apply video texture on emissiveMap of MeshStandardMaterial
  • make emissive color white and diffuse color black so its simulating a real life 'display/screen/tv'
  • notice the video's colors look washed out as its displaying in Linear Color Space

Code

 const videoTexture = new THREE.VideoTexture(videoElem)
 videoTexture.colorSpace = THREE.SRGBColorSpace
 
 const emit_mesh = new THREE.Mesh(planeGeometry, new THREE.MeshStandardMaterial({
    color: 0x000000,
    emissive: 0xffffff,
    emissiveMap: videoTexture,
  }))
  scene.add(emit_mesh)

Live example

In this demo jsfiddle.net

The same VideoTexture and an ImageTexture is applied on

emissiveMap input of a MeshStandardMaterial
map input of a MeshStandardMaterial
map input of a MeshBasicMaterial

& GUI controls colorSpace of both

Screenshots

(look at the top right plane in this video)

Untitled.video.-.Made.with.Clipchamp.mp4

Version

r169

Device

Desktop

Browser

Chrome

OS

Windows

@donmccurdy
Copy link
Collaborator

donmccurdy commented Oct 11, 2024

Related:

Currently VideoTexture is a special case because the browser's sRGB decoding is unreliable for videos. Perhaps we need to extend the inline GLSL sRGB decoding to other slots on default materials.

The underlying browser issues remain unfixed.

@donmccurdy
Copy link
Collaborator

donmccurdy commented Oct 14, 2024

@Mugen87 I don't mind making a PR for this, is it OK to scope the fix only to .emissiveMap? Technically this also applies to .sheenColorMap, .specularColorMap, etc... but I doubt these are being used with video, and I imagine we might not want this chunk appearing everywhere:

#ifdef DECODE_VIDEO_TEXTURE

  // use inline sRGB decode until browsers properly support SRGB8_ALPHA8 with video textures (#26516)

  sampledDiffuseColor = vec4( mix( pow( sampledDiffuseColor.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), sampledDiffuseColor.rgb * 0.0773993808, vec3( lessThanEqual( sampledDiffuseColor.rgb, vec3( 0.04045 ) ) ) ), sampledDiffuseColor.w );
	
#endif

We could log a warning when video textures use SRGBColorSpace on an unsupported slot, perhaps.

Aside, which of these blocks us from using WebGL's sRGB decoding for video?

Do we need both fixed, or just the Safari one?

@Mugen87
Copy link
Collaborator

Mugen87 commented Oct 14, 2024

Supporting just emissive sounds good to me!

AFAICS, we need both browser bugs fixed.

@donmccurdy
Copy link
Collaborator

PR

@Mugen87 Mugen87 added this to the r170 milestone Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants