-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
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
outputEncoding not handled correctly when using sRGB render target in WebGL2 #23251
Comments
Looks like the same problem also exists at three.js/src/renderers/WebGLRenderer.js Line 1418 in 6f7a821
|
The inline shader sRGB encode only needs to be done for the default framebuffer. Let me fix this with a PR. Right now, the render target is sRGB encoded two times (inline and by WebGL). |
I want to make clear that the fiddles are great for reproducing the issue. However, the fiddles are probably no good approach for code used in production. In almost all cases, you only want to apply sRGB encoding when rendering to screen. Otherwise you encode/decode sRGB values in each pass of your FX chain since normally you want linear values in the shaders. This encoding/decoding overhead is waste from my point of view. The fiddle should actually look like so: https://jsfiddle.net/2j4nzcra/ |
Related #23019. |
In production I'll still use code like the original fiddle. Per my understanding, the purpose of allowing framebuffer color attachment format to be |
I've referred with my comment to FX setups with multiple passes. sRGB should be applied at the end. Intermediate frame buffers should be linear. |
Sorry which comment? |
Yes, we want linear values in the shaders, but srgb values in 8 bit images. I'll make a fiddle tomorrow to show the case. |
To provide some additional information on the topic: Storing linear colors in 8bit buffers causes color degradation and banding. Linear colors should only be stored with at least 12 bits of precision per channel to avoid this (reference).
This is correct, but it requires |
To show how the effect looks like in three: linear framebuffer. Color is quantized in linear space then converted to sRGB space for displaying. Notice the banding effect. srgb framebuffer. Color is first converted to sRGB space then quantized and displayed. Much smoother. |
Describe the bug
In #23129, the
outputEncoding
is calculated differently from before. I believe the previous way is correct.To Reproduce
See following code and fiddle.
Code
Live example
Expected behavior
dev
should behave the same asr136
.Screenshots
r136
dev
Platform:
The text was updated successfully, but these errors were encountered: