Closed msparkles closed 1 year ago
Does this happen in the examples also on your system?
No, we figured that it seems to be a problem with coloured text.
We hacked together a fork, the tl;dr is that we just remove the SRGB conversion stuff.
The SRGB conversion in the shader is used only if the surface format being passed to the library is of linear type.
Colors should work fine too. Try passing the preferred_format
(of the swapchain image format) to the Gui::new()
.
See example demo_app.rs
.
Preferred format fixes it, yes, but then transparency seems wrong. demo_app.rs seems to not have transparency?
Strictly speaking, we're using a more light-mode theming.
We fixed(/hacked) the transparency issue by doing this + removing SRGB conversions:
let a = v.color.a() as f32 / 255.0;
EguiVertex {
position: [v.pos.x, v.pos.y],
tex_coords: [v.uv.x, v.uv.y],
color: [
v.color.r() as f32 / 255.0 * a,
v.color.g() as f32 / 255.0 * a,
v.color.b() as f32 / 255.0 * a,
a,
],
}
It's been a while since I played with the colors, but I never got the color test to match 100% similar to egui web demos. But almost. With both linear and non-linear color space surfaces.
Anyway, I did notice that the pipeline was potentially using a different alpha blending. Can you try if this branch helps? Along with the preferred format.
As far as I know, the egui vertex color values shouldn't be multiplied by alpha again. Meaning they say on their github
egui uses premultiplied alpha
I'd be curious to see another screenshot or a small example of the gui code to better understand what you mean, perhaps I can test on my end also then.
Gonna pull the changes from within my own hack-y fork to test.
(Our code outside is incompatible because of the Multisampling hack-- they're there because otherwise its impossible to multisample on PaintCallbacks)
Hmm...
The passed preferred image format is B8G8R8A8_UNORM (picked from the available formats)
Our code is at https://github.com/Mg138/automancy
It's a bit complicated, we'll make a minimally reproducible example if needed.
EDIT: We did change the from_premultiplied_rgba to from_unmultiplied_rgba in our local testing code, just so you know.
It's recommended to us B8G8R8A8_SRGB
, because egui prefers that.
I've switched all my projects to use SRGB
because it looks better. And most images exist in SRGB color space by default.
I've modified the PR #37 a bit to enable multisampling too. Let me know if that helps. I could add some other options to GuiConfig
(new struct to pass options), if needed.
I also modified the subpass
example to display a window with transparency under which there is a triangle. That works fine too, but it does look bad if using UNORM color space.
Wanna also show a comparison of the hex image without your fixes? So I'll know what the "bad" look is in that context? I'll still have to figure out what's correct here...
We think we'll try to switch to SRGB for now. Maybe say it somewhere to recommend using it?
We think that an option for multisampling states and whatnot would be great!
The hexes aren't really the problem here, enabling multisampling kinda automagically fixed the hexes. The text problem seemed to be entirely about the colorspace. We'll close the issue if switching to SRGB fixes it -- there may be shenanigans going on because of the swapchain format being UNORM?
The swapchain image ahould also be srgb.
I merged my updates & released. I hope that makes this library just a bit more useful for you :).
Added also a multisample example, which is basically similar to subpass one, but mutlisampled.
The game looks very nice now, thanks!
Is text anti-aliasing a thing?
Text don't seem to render too well.