-
-
Notifications
You must be signed in to change notification settings - Fork 36k
WebGLRenderer: Default output to sRGB #25783
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
WebGLRenderer: Default output to sRGB #25783
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
Could we also set |
|
Related #23614 (comment) |
| this.autoClearStencil = true; | ||
|
|
||
| this.outputColorSpace = LinearSRGBColorSpace; | ||
| this.outputColorSpace = SRGBColorSpace; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh! I almost forgot...
I think this should be:
this.outputColorSpace = null;This default will let the renderer use SRGBColorSpace or DisplayP3ColorSpace automatically based on the user's display (eventually).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it already clear how the renderer will determine the user's display color space? I suppose there will be a special Web API for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do this check: #23614 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By setting it to null it will also leave the door open for HDRColorSpace or whatever we get in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can do this check: #23614 (comment)
Interesting! Couldn't we implement this check in the ctor call of the renderers? I suppose the user's display color space is not something that is going to change during app usage.
I just wonder how and when the renderer determines the output color space. If the default value is null and the user is not going to define the color space (which will be true most of the time), the renderer has to set the value eventually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright. Lets do that 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW: DCI-P3 related features are tracked by the task 2.2 in #23614.
Looking at the spec, I wonder if defining DisplayP3ColorSpace is sufficient. Is it required to change the WebGLRenderingContext.drawingBufferColorSpace, too? It accepts srgb and display-p3 with srgb as the default.
When I change this property in any three.js example to display-p3, I can actually see a hue shift. I wonder now which setup (values of output color space and drawing buffer color space) is actually correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's enable color management by default first before going for the DisplayP3ColorSpace change. We need the color space conversion in any event to get the colors in DisplayP3ColorSpace right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as far as I understand we do not have the shaders chunks needed for supporting DisplayP3ColorSpace as output yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if encodings_fragment were implemented for Display P3, I'm not sure yet when it should be turned on. The difference when enabling it for existing content is very subtle — not an automatic improvement.
There are more impactful results when bringing in wide-gamut colors and textures in scenes designed for Display P3, particularly for unlit scenes. Or perhaps for rendering lit scenes in a wide-gamut working color space (not just wide-gamut output color space). But either of those will require more investigation.
For now I think we should not auto-detect — SRGBColorSpace will be the right default for a while yet.




Changes in this PR:
With r152, the default behavior in three.js will be to perform rendering in Linear-sRGB, with output to the canvas converted automatically to sRGB. WebGL and WebGPU APIs already assume that colors written to the canvas are sRGB. Many three.js examples already opt-in to this behavior, and the remainder will be updated over time.
There are limited cases where output to Linear-sRGB may be preferable, such as saving output to an HDR image, or some situations involving post-processing. For the large majority of users however, we recommend keeping this new default output (sRGB) and assigning input colors accordingly. Use of
THREE.ColorManagement.enabled = truecan be very helpful in making that switch.Statistics for all WebGL and WebGPU examples:
Scripts for statistics
All unspecified examples now use sRGB implicitly. 71 examples use
ColorManagement.enabled = true. Please refer to the color management documentation for background and best practices.In many cases, adding
THREE.ColorManagement.enabled = trueto an example and assigningtexture.colorSpace = THREE.SRGBColorSpaceappropriately was enough to complete the migration. Remaining cases will require some manual conversion of colors, and/or adjustments to scene lighting. This change tends to make shading appear a bit softer, and a few examples lacked contrast after the change. I've included the easier migrations in this PR, and opted-out on the rest.Remaining changes for r152, in next PRs:
Related issue: