Skip to content

Commit c3b0c87

Browse files
Antialias checkered artboard background edges (#4163)
* Antialias checkered artboard background edges * Review
1 parent 2770df7 commit c3b0c87

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

node-graph/libraries/wgpu-executor/src/background/checker_rect.wgsl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ fn vs_main(@builtin(vertex_index) vertex_index: u32) -> VertexOutput {
4444
fn fs_main(in: VertexOutput) -> @location(0) vec4<f32> {
4545
let tile = floor((in.document_position - uniforms.pattern_origin) / uniforms.checker_size);
4646
let parity = i32(tile.x + tile.y) & 1;
47-
let luminance = vec3<f32>(select(1.0, 0.8, parity == 1));
48-
return vec4<f32>(luminance, 1.0);
47+
let luminance = select(1.0, 0.8, parity == 1);
48+
49+
let fw = fwidthFine(in.document_position);
50+
let coverage_max = 1.0 - smoothstep(uniforms.rect_max - fw, uniforms.rect_max, in.document_position);
51+
let coverage_min = smoothstep(uniforms.rect_min, uniforms.rect_min + fw, in.document_position);
52+
let coverage = coverage_max * coverage_min;
53+
let alpha = coverage.x * coverage.y;
54+
55+
return vec4<f32>(vec3<f32>(luminance), alpha);
4956
}

node-graph/libraries/wgpu-executor/src/background/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl BackgroundCompositor {
8686
compilation_options: Default::default(),
8787
targets: &[Some(wgpu::ColorTargetState {
8888
format,
89-
blend: None,
89+
blend: Some(wgpu::BlendState::ALPHA_BLENDING),
9090
write_mask: wgpu::ColorWrites::ALL,
9191
})],
9292
}),

0 commit comments

Comments
 (0)