-
Notifications
You must be signed in to change notification settings - Fork 12
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
broken ColorTest with cpu rendering #6
Comments
Some errors could be fixed by un-premultiplying colors from diff --git a/src/painter.rs b/src/painter.rs
index 5c07f5b..8696332 100644
--- a/src/painter.rs
+++ b/src/painter.rs
@@ -205,11 +205,19 @@ impl Painter {
pos.push(Point::new(fixed_pos.x, fixed_pos.y));
texs.push(Point::new(v.uv.x, v.uv.y));
+
+ let c = v.color;
+ let c = Color::from_argb(c.a(), c.r(), c.g(), c.b());
+ // un-premultply color
+ let mut cf = skia_safe::Color4f::from(c);
+ cf.r /= cf.a;
+ cf.g /= cf.a;
+ cf.b /= cf.a;
colors.push(Color::from_argb(
- v.color.a(),
- v.color.r(),
- v.color.g(),
- v.color.b(),
+ c.a(),
+ (cf.r * 255.0) as u8,
+ (cf.g * 255.0) as u8,
+ (cf.b * 255.0) as u8,
));
}); |
Hi! I applied your fix in #7, improving on the color test results. But as you already mentioned it's not perfect yet so I'll leave this issue open for now. |
The colors on rendered images are all messed up (weird pink tinge), I wonder if this is related? |
I tried rendering a gradient texture and when I sample the color with a color picker, the red and the blue components appear to be swapped. I fixed it with this: let scol = [0x1E, 0x55, 0xFF];
let ecol = [0xFA, 0x0D, 0xD4];
// TODO: skia has r/b colors swapped for some reason, fix this
let start_color = Color32::from_rgb(scol[2], scol[1], scol[0]);
let end_color = Color32::from_rgb(ecol[2], ecol[1], ecol[0]);
let gradient = Gradient::linear(start_color, end_color); before: https://cdn.jb55.com/s/0cdefad30a081797.png |
While tracking down rendering errors, I found that color rendering is broken with cpu rendering (
cpu_fix
).Here's a code snippet to render ColorTest.
This is cpu-rendered image, generate from a code above, which shows errors.
Here's a side-by-side screenshot, comparing cpu-rendered with webgl one (from https://egui.rs)
The text was updated successfully, but these errors were encountered: