-
-
Notifications
You must be signed in to change notification settings - Fork 10.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
sRGB framebuffer and color-edit gradients #4890
Comments
After a lot of testing and playing around this is related to the alpha channels. The black/grey ramp is blended over the white/blue ramp. So, I assume that we get sRGB/non-linear colors into the shader and blend them using the hardware (which I assume blends in linear space). I think there is no way of getting the right result just by adapting the shader here. |
It would be most convenient to allow the programmer to specify a colour-space for imgui to output to when the Vulkan backend is in use, so that the programmer doesn't need to build their render passes around what imgui expects. |
Same answer, but PR for this are welcome. |
I was looking at this as well and seeing how converting form SRGB -> Linear at the vertex level fixes the colours in the rest of the widgets but not the ColorPicker3/4 SV square. I believe it must come from the way its done with a horizontal gradient first from white to the hue colour, then a vertical one from transparent black to opaque black. Lines 5516 to 5518 in cc3a220
Because the hardware will take both sRGB values, convert to linear, then blend and convert back to sRGB. The vertical gradient will essentially show up as if it was done in linear space as @chrislu said. I'm wondering if there's a way to get around this with the current functionality (while keeping the SRGB framebuffer/swapchain view). You could fiddle with the alpha of that second black gradient on the pixel shader, but not in a generic way that I can see yet. Modifying the vertex colours at the source won't do anything because what we want to change here is the curve of the interpolated vertex values on the pixel shader if we can't change how they blend. |
I tried locally a version of the SV square that just renders a grid of quads and it goes back to rendering as expected. But it's obviously slower and takes more verts. Code could be made much better but just to confirm that this was the issue:
Another drawback is that depending on how many quads you draw you can get to a point where you see the interpolation artifacts. Then I checked the original issue to add a colour picker. And it seems that originally the code ran in a similar way, then got changed to the smarter two-draw method. |
Hi,
I am using imgui under Vulkan with a sRGB framebuffer (
VK_FORMAT_B8G8R8A8_SRGB
). I modified the fragment shader so linearize the colors before writing them out to the framebuffer:The result is pretty much what I would expect. However, I noticed that the colorpicker gradients are still off:
The left is the sRGB framebuffer with my changes applied to the imgui shader. The right is plain imgui on a standard unorm framebuffer.
This is really strange as I tried several things like linearizing in the vertex shader. The result is always the same. All colors change, even the hue-slider changes as expected BUT not the large gradient box. I also tried wild things like inverting the
In.Color.rgb
values and these changes applied to the gradient. Also notice the alpha gradient also is off.What do I have to change to also get these gradients to render correctly on an sRGB framebuffer?
Thanks
-chris
The text was updated successfully, but these errors were encountered: