Skip to content

Commit a90b939

Browse files
authored
vello_hybrid: Fix pixel coord -> NDC transform (#870)
I believe the coordinate systems are aligned at the pixel edge, not the pixel center. This fixes rendering artifacts on my system (AMD GPU), where with the previous shader code the locations sampled during fragment shading probably sometimes got bumped to the next pixels. This should be confirmed to work on systems where it worked previously as well.
1 parent bd74626 commit a90b939

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sparse_strips/vello_hybrid/shaders/sparse_strip_renderer.wgsl

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ fn vs_main(
6969
let pix_y = f32(y0) + y * f32(config.strip_height);
7070
// Convert pixel coordinates to normalized device coordinates (NDC)
7171
// NDC ranges from -1 to 1, with (0,0) at the center of the viewport
72-
let ndc_x = (pix_x + 0.5) * 2.0 / f32(config.width) - 1.0;
73-
let ndc_y = 1.0 - (pix_y + 0.5) * 2.0 / f32(config.height);
72+
let ndc_x = pix_x * 2.0 / f32(config.width) - 1.0;
73+
let ndc_y = 1.0 - pix_y * 2.0 / f32(config.height);
7474

7575
out.position = vec4<f32>(ndc_x, ndc_y, 0.0, 1.0);
7676
out.tex_coord = vec2<f32>(f32(instance.col) + x * f32(width), y * f32(config.strip_height));

0 commit comments

Comments
 (0)