-
-
Notifications
You must be signed in to change notification settings - Fork 24k
VisualShader: Add LinearToSRGB and SRGBToLinear to ColorFunc node #97388
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
VisualShader: Add LinearToSRGB and SRGBToLinear to ColorFunc node #97388
Conversation
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.
Originally, I wanted to suggest switching the computation based on the current renderer, but after looking at the referenced blog article, I think it would be fine to just use the compatibility version (since it's a very good approximation). Maybe it can be used for RD renderers as well. CC @clayjohn
|
All else being equal, the visual shader node should be accurate to whatever computation is used in the current renderer (or, if it must make assumptions, favor the Forward+ and Mobile renderers). |
4c382df to
22b86ee
Compare
|
The computation now depends on the renderer, exactly matching whichever computation is used internally. |
22b86ee to
2191df0
Compare
Mickeon
left a 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.
Assuming accuracy, the docs are completely fine.
|
Thanks! |
|
I have been working on the HDR output PR, which requires the use of HDR buffers. This PR is useful because it allows simulation of traditional blending with nonlinear sRGB-encoded values, while still using HDR buffers. This approach involves performing a linear to sRGB conversion, applying blending or other shader operations, and then converting back to linear. Especially when using HDR output it is important that all HDR values are maintained (values above I understand that "this is the way it was previously done in many shader files in Godot", but in these previous cases it wouldn't have an impact because the colour value was immediately written to a buffer that clamps to [0, 1]. The use case for this node is different: it is expected that the user may be converting to and from nonlinear-sRGB encoding to achieve different effects. If they want to clamp, they can do so with the Is there a reason that the clamp function was included in this node for Mobile and Forward+? |
Implements and closes godotengine/godot-proposals#10818.
Adds LinearToSRGB and SRGBToLinear conversions to the visual shader node
ColorFunc.Implementation:
This node automatically switches it's conversion function depending on which renderer is used.
The RenderingDevice (Forward+ and Mobile Renderer) conversion functions:
godot/servers/rendering/renderer_rd/shaders/effects/copy_to_fb.glsl
Lines 121 to 130 in 4254946
The Compatibility renderer uses slightly different functions:
godot/drivers/gles3/shaders/tonemap_inc.glsl
Lines 13 to 26 in 4254946
If #90187 is merged, and the change in that PR is also made to the GLSL version of the
linear_to_srgbandsrgb_to_linearfunctions, then this visual shader node will need to be updated.