From 2d4d856e55ffa484a932c8a122391908663a39a8 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sat, 21 May 2022 12:14:05 -0700 Subject: [PATCH] examples/gkurve: fix bug in barycentric coordinates Signed-off-by: Stephen Gutekanst --- examples/gkurve/vert.wgsl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/gkurve/vert.wgsl b/examples/gkurve/vert.wgsl index 18d9fe0e..d3e835d4 100644 --- a/examples/gkurve/vert.wgsl +++ b/examples/gkurve/vert.wgsl @@ -19,7 +19,7 @@ struct VertexOut { output.position_clip = ubo.matrix * position; output.frag_uv = uv; - // Generates [0, 0], [0.5, 0.0], [1.0, 1.0] + // Generates [0.0, 0.0], [0.5, 0.0], [1.0, 1.0] // // Equal to: // @@ -32,8 +32,8 @@ struct VertexOut { // } // output.frag_bary = vec2( - f32(((vertex_index+2u) % 3u * 2u) % 3u), - f32(((vertex_index+2u) % 3u * 2u) & 2u) * 2.0, + f32((vertex_index+1u) % 3u) * 0.5, + 1.0 - f32((((vertex_index + 3u) % 3u) + 1u) % 2u), ); output.triangle_index = vertex_index / 3u; return output;