lucasmerlin / egui_skia

Render egui with skia!
MIT License
57 stars 13 forks source link

Minor rendering differences between skia and wgpu backend #14

Open DorianRudolph opened 11 months ago

DorianRudolph commented 11 months ago

I'm comparing the winit+metal example of egui_skia with the egui_demo_app wgpu. It seems like the text in egui_skia is slightly off and harder to read. Also, the highlight around the text box appears less vibrant and has white points in the corners. This is only noticeable for me on a non-retina screen. The white dots are also in the corners of the right sidebar.

Here is a screenshot from the code editor example:

skia: image

wgpu: image

Both at 400% image

EDIT:

Perhaps this could be related to some alpha blending issue? Perhaps related to gamma (not quite sure yet what that it is, but egui says in the release notes that since 0.20.0 all color blending has to be done in gamma space)? In the Bezier curve example, the blended red and green colors on the checkboard background look much lighter in skia. The antialasing is also off, perhaps because egui uses alpha for anti aliasing.

skia: image

wgpu: image

DorianRudolph commented 11 months ago

image

Antialiasing at least seems to work better with

layer.set_pixel_format(MTLPixelFormat::RGBA8Unorm_sRGB);

Surface::from_backend_render_target(...,  ColorType::SRGBA8888, ...)

let r = linear_u8_from_linear_f32(linear_f32_from_gamma_u8(c.r()));
let g = linear_u8_from_linear_f32(linear_f32_from_gamma_u8(c.g()));
let b = linear_u8_from_linear_f32(linear_f32_from_gamma_u8(c.b()));
colors.push(Color::from_argb(c.a(), r, g, b));

But this is also not quite correct. The surface is not supposed to be srgb.