-
-
Notifications
You must be signed in to change notification settings - Fork 21.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
GPUParticles2D colors are being rendered darker than expected #80025
Comments
This is likely a sRGB-to-linear conversion issue (or vice versa). To confirm this, set the color to the result |
This comes from an interesting limitation in the Particles process shaders. When passing uniform colors to shaders, we have some logic to automatically convert the color to linear if it is being used in a shader where colors should be in linear space (spatial shader, sky shader, etc.) However, Particle process shaders can be either linear space (for 3D shaders) or sRGB space (for 2D shaders). During the actual particles process shader, there is no way to tell if you are going to use the particles in 2D or in 3D. One option would be to always do the processing in sRGB space, then force 3D users to set the "vertex_is_srgb" flag in their material. But that would break compatibility, so isn't really a good option. We should probably investigate giving the material some awareness of where it is used. But even that is tricky as process material uniforms are updated independently from the particles. We might be able to figure something out using a shader variation though. As the process update step has knowledge of the particles node and whether it is 2D or 3D. I guess what could work is the following:
|
I had some more ideas while working on #80215 I think I have a solution in mind that should be ideal:
This should make everything "just work" and won't be a lot of work to implement. But it relies on #80215 being merged first |
@clayjohn could be also something that we can tie to disable_z flag, since that's mostly used for 2D (a bit hacky tho) |
Any update on this @clayjohn? Not well-versed on this stuff but enabling 2D HDR also makes the particle colour ramps display colours incorrectly, but oddly the particle colour is displayed correctly only when it is enabled. HDR off (fire particles are correct, smoke is darker than it should be): |
@vybr Out of curiosity, do any of your colour ramps contain alpha channel values below 1.0 (i.e., particle transparency)? Your second colour ramp for smoke looks like it might have a white center, with a bit of a feathered (lower alpha?) near the edges, but I can't tell from your image if this is a decrease in alpha, or just a darker grey RGB colour. My understanding is that the HDR changes will result in normal RGB values appearing slightly different, as they are converted from sRGB gamma-corrected colour space to linear RGB space. I'm still trying to determine if alpha channel values receives this same conversion treatment with Godot's forward renderer, and if so - whether that's the correct way to handle alpha channel colour space conversion. Check #80868 for some related discussion. |
Just as a note, the documentation says that the Color property is multiplied by the texture colors. If the intended behavior is to do something other than an element-by-element multiplication (such as a nonlinear conversion), I think the documentation needs adjustment to describe what the intended behavior is.
As is, I'm trying to sample pixel colors from a texture to dynamically break it apart into particles, and it's very unexpected to not multiply a (1,1,1,1) white texture by my sampled colors and get those exact sampled colors back out. |
Godot version
v4.2.dev.custom_build [75f9c97]
System information
Windows 11 - Godot 4.1.1 / master [75f9c97] - AMD RX6800, Vulkan Forward/Mobile
Issue description
Particles from GPUParticles2D are being rendered darker than expected with the Vulkan backend, for both forward and mobile.
I noticed this with Godot 4.1.1 and the issue is still present on 75f9c97.
Steps to reproduce
Create GPUParticles2D with default ParticlesMaterial, change color, set scale, compare to ColorRect with same RGB value.
Minimal reproduction project
N/A
The text was updated successfully, but these errors were encountered: