diff --git a/piet-wgsl/shader/fine.wgsl b/piet-wgsl/shader/fine.wgsl index 4431848..ad3772c 100644 --- a/piet-wgsl/shader/fine.wgsl +++ b/piet-wgsl/shader/fine.wgsl @@ -142,7 +142,7 @@ fn main( // CMD_COLOR case 5u: { 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) { let fg_i = fg * area[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; 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(fg.r * a_inv, fg.g * a_inv, fg.b * a_inv, fg.a); + let bytes = pack4x8unorm(rgba_sep); output[out_ix + i] = bytes; } #else diff --git a/piet-wgsl/src/test_scene.rs b/piet-wgsl/src/test_scene.rs index 1029c59..c0c9390 100644 --- a/piet-wgsl/src/test_scene.rs +++ b/piet-wgsl/src/test_scene.rs @@ -27,19 +27,10 @@ pub fn gen_test_scene() -> Scene { PathElement::LineTo(Point::new(150.0, 210.0)), 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); - let transform = Affine::translate(10.0, 200.0); - /* - 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, - ]; - */ + let transform = Affine::translate(50.0, 50.0); + let brush = Brush::Solid(Color::rgba8(0xff, 0xff, 0x00, 0x80)); builder.fill(Fill::NonZero, transform, &brush, None, &path); scene }