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

Editor: Background textures (PNG, JPG, ...) should assume sRGB #30788

Closed
donmccurdy opened this issue Mar 24, 2025 · 2 comments · Fixed by #30794
Closed

Editor: Background textures (PNG, JPG, ...) should assume sRGB #30788

donmccurdy opened this issue Mar 24, 2025 · 2 comments · Fixed by #30794
Milestone

Comments

@donmccurdy
Copy link
Collaborator

donmccurdy commented Mar 24, 2025

Description

Originally reported in:

https://discourse.threejs.org/t/scene-texture-background-is-lighter-than-image-used/38362

It appears that the editor currently assumes background textures use the working color space, LinearSRGBColorSpace. That's probably correct for .exr or .hdr textures, but it's unlikely that non-HDR textures in PNG/JPG/WebP/AVIF/... formats will be linear. We should assume that these formats are sRGB, like material.map.

The incorrect (lighter) output in the issue report is the result expected if we set background.colorSpace to NoColorSpace or LinearSRGBColorSpace, when it should be SRGBColorSpace.

I've checked that fog and tone mapping are not involved in this case. We can get the same result by doing a linear-to-sRGB conversion on the already-srgb input:

oiiotool -i ~/Downloads/background.jpeg --iscolorspace lin_srgb --colorconvert lin_srgb srgb -o ~/Downloads/background_srgb_oetf.jpeg

Reproduction steps

  1. add background texture to Editor (see link)
  2. observe lighter background than expected

Code

n/a

Live example

n/a

Screenshots

Expected

Image

Actual

Image

Version

r174

Device

No response

Browser

No response

OS

No response

@Mugen87
Copy link
Collaborator

Mugen87 commented Mar 25, 2025

There are a couple of strategies to fix this issue.

  • Evaluate the file extension although that assumption might be incorrect. E.g. UltraHDR files are JPGs.
  • Add a select box that specifies the color space of the background texture.
  • Or alternatively a select box that allows to choose between HDR or SDR.

I vote for option 2.

@donmccurdy
Copy link
Collaborator Author

donmccurdy commented Mar 25, 2025

If we know from context (scene.background) that it's a color texture, then I think a solid default choice would be sRGB for 8-bit textures and Linear-sRGB for >=16-bit textures. If we want to do (2) as well that's even better.

I would avoid the HDR/SDR terms in this UI, I think they're too ambiguous.

@Mugen87 Mugen87 added this to the r175 milestone Mar 25, 2025
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.

2 participants