-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
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
Using vec4 values in canvas_item shaders appear washed out when 2D HDR is active. #84989
Comments
I can confirm that this is also in 4.2 RC 1 |
I can confirm this on 4.2.rc1 (Linux, GeForce RTX 4090 with NVIDIA 535.129.03). This also occurs with Using the Canvas background mode in Environment and playing with tonemap properties doesn't yield the expected appearance, so the issue is somewhere else. A Sprite2D with Edit: Disregard the accidental close/reopen above. |
Ran into this issue as well when I needed to compare colors in a shader. Textures passed into the main texture property of e.g. Sprite2D appear to remain untouched, while textures and/or colors passed via uniforms and even shader constants are converted; appear brighter. here's some illustrations: the shader displays the very same texture differently depending on whether its passed via uniform or taken from Sprite2D's texture property. Colors passed via uniform and even shader constants are affected, too: when trying to compare the two supposedly identical colors in the shader (for instance via edit: clayjohn just explained to me on rocket chat that we are supposed to use the my specs: |
This is exactly an sRGB vs linear issue. I color-picked the comparisons pictures posted by OP and the difference was exactly the sRGB conversion. I'm not familiar enough with the whole pipeline in 2D rendering to fix this issue, and what Godot should be doing (probably what users expect? isn't that a bit subjective? Maybe a checkbox to toggle automatic conversion). In case someone wants to take a stab at this problem, the conversion routines (which should happen in the CPU so they're sent already converted to the GPU) are here. |
I believe that any viewport running with HDR 2D enabled should do automatic conversion for all "source_color" shader parameters. Do any of the folks with more experience working in engine code see a flaw in that simple conclusion? |
I don't see in flaw in your conclusion. You describe how it's supposed to work. That's why this is labelled as a bug. |
Clay: your wording is confusing. You're making it sound like you're in disagreement with what JohnPadlich said but reading it carefully you're both in agreement. |
Oops, updated my wording to be more clear that "nope" means "I don't see a flaw in your conclusion" |
I have done an initial dive into approaching this issue and I am including my notes in this ticket. My goal was to see where Sampler2D's "source_color" was accounted for and how this translated into a linear_to_sRGB conversion.
`
`
`
Unfortunately I do not have a clear idea on how to approach this yet. It seems as though it would be relatively straight forward to mark source_color for vec3 and vec4 uniforms and to do a linear_to_srgb conversion in shader_compiler._dump_node_code storing 2 values, 1 converted and one unconverted. The more difficult problem to address is how to propagate HDR 2D information when rendering and to actually choose the appropriate value. Any suggestions by someone with more experience in engine code is greatly appreciated. |
On my next dive I will look into how uniforms are updated via GDScript's "set_shader_parameter" utilize that logic to find a way to inject if HDR 2D is being used via the material. (Hopefully in the next few months.) |
Just wanted to report something similar. To my understanding |
Is there any current workaround for this? I would love to update my steam screenshots and i am planning to create my initial trailer soon so would like my game to look as pretty as possible. I tried adjusting colour conversion but it didn't work. |
@produno As a work around you can add a 1 pixel texture of the color and use that. Best of luck. |
I'm assuming this is going to get fixed in some later update to Godot, but in the meantime, if there are other people like me looking to use HDR 2D for its glow effects while trying to avoid messing up the colors on your 2D shaders, the following code's worked for me:
|
@Calinou do we have any fix for this on the current snapshot of godot 4.3, or at least a planned fix for the upcoming beta? I skimmed through the changelog of the former but couldn't find anything. |
Thank you, this worked as a workaround. |
It's not fixed in 4.3 dev 6. I have not seen anything indicating it will be fixed for 4.3. |
When a fix is merged, this issue report will be closed. As long as this is open, the issue remains unfixed |
Godot version
4.2 beta 6
System information
Linux Mint, Forward+, ntel© Xeon© CPU E5-2650 v4 @ 2.20GHz × 12, 64gb ram
Issue description
When using a canvas item shader, vec4 values appear washed out when 2D HDR is activated. Anecdotally, glows seem to appear more bland and white than in 3.x when I would expect them to be more "dynamic". This leads me to believe there is an issue with 2D HDR's sRGB -> linear conversion.
With 2D HDR:
With out 2D HDR:
Steps to reproduce
To reproduce:
Enable "HDR 2D" in Rendering -> Viewport settings
Create a Sprite2D in a scene
Add a shader to that Sprite2D's material with a vec4 color that is not black or white, but in the mid range.
Set the COLOR in the fragment fragment function to a value from the vec4.
To view this issue in the "minimal reproduction project", open the scene named "repro.tscn" and activate/deactivate 2D HDR.
Minimal reproduction project
ColorRepro.zip
The text was updated successfully, but these errors were encountered: