mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
Fix color
Get rgba order right in rendering, plus generate separated alpha for png. The latter is just for debugging, we won't generally use separated alpha.
This commit is contained in:
parent
c3d81e0985
commit
92d6b1188f
|
@ -142,7 +142,7 @@ fn main(
|
||||||
// CMD_COLOR
|
// CMD_COLOR
|
||||||
case 5u: {
|
case 5u: {
|
||||||
let color = read_color(cmd_ix);
|
let color = read_color(cmd_ix);
|
||||||
let fg = unpack4x8unorm(color.rgba_color);
|
let fg = unpack4x8unorm(color.rgba_color).wzyx;
|
||||||
for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
|
for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
|
||||||
let fg_i = fg * area[i];
|
let fg_i = fg * area[i];
|
||||||
rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
|
rgba[i] = rgba[i] * (1.0 - fg_i.a) + fg_i;
|
||||||
|
@ -158,7 +158,10 @@ fn main(
|
||||||
}
|
}
|
||||||
let out_ix = global_id.y * (config.width_in_tiles * TILE_WIDTH) + global_id.x * PIXELS_PER_THREAD;
|
let out_ix = global_id.y * (config.width_in_tiles * TILE_WIDTH) + global_id.x * PIXELS_PER_THREAD;
|
||||||
for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
|
for (var i = 0u; i < PIXELS_PER_THREAD; i += 1u) {
|
||||||
let bytes = pack4x8unorm(rgba[i]);
|
let fg = rgba[i];
|
||||||
|
let a_inv = 1.0 / (fg.a + 1e-6);
|
||||||
|
let rgba_sep = vec4<f32>(fg.r * a_inv, fg.g * a_inv, fg.b * a_inv, fg.a);
|
||||||
|
let bytes = pack4x8unorm(rgba_sep);
|
||||||
output[out_ix + i] = bytes;
|
output[out_ix + i] = bytes;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -27,19 +27,10 @@ pub fn gen_test_scene() -> Scene {
|
||||||
PathElement::LineTo(Point::new(150.0, 210.0)),
|
PathElement::LineTo(Point::new(150.0, 210.0)),
|
||||||
PathElement::Close,
|
PathElement::Close,
|
||||||
];
|
];
|
||||||
let brush = Brush::Solid(Color::rgb8(0x80, 0x80, 0x80));
|
let brush = Brush::Solid(Color::rgb8(0x40, 0x40, 0xff));
|
||||||
builder.fill(Fill::NonZero, Affine::IDENTITY, &brush, None, &path);
|
builder.fill(Fill::NonZero, Affine::IDENTITY, &brush, None, &path);
|
||||||
let transform = Affine::translate(10.0, 200.0);
|
let transform = Affine::translate(50.0, 50.0);
|
||||||
/*
|
let brush = Brush::Solid(Color::rgba8(0xff, 0xff, 0x00, 0x80));
|
||||||
let path = [
|
|
||||||
PathElement::MoveTo(Point::new(100.0, 300.0)),
|
|
||||||
PathElement::LineTo(Point::new(500.0, 320.0)),
|
|
||||||
PathElement::LineTo(Point::new(300.0, 350.0)),
|
|
||||||
PathElement::LineTo(Point::new(200.0, 460.0)),
|
|
||||||
PathElement::LineTo(Point::new(150.0, 410.0)),
|
|
||||||
PathElement::Close,
|
|
||||||
];
|
|
||||||
*/
|
|
||||||
builder.fill(Fill::NonZero, transform, &brush, None, &path);
|
builder.fill(Fill::NonZero, transform, &brush, None, &path);
|
||||||
scene
|
scene
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue