fix: use rounded-square SDF for cursor avoidance hole
Replace Chebyshev distance with a rounded box SDF for the cursor avoidance shape. Eliminates diagonal artifacts where the sharp corners of a pure square distance field intersected the ring geometry.
This commit is contained in:
2 files changed
+11
-13
No files matched your search
+6
-6
@@ -60,12 +60,12 @@ fn fs_main(@builtin(position) pos: vec4f) -> @location(0) vec4f {
|
||||
alpha = exp(-3.0 * t * t);
|
||||
}
|
||||
|
||||
// Cursor avoidance
|
||||
let cursor_dist = distance(pos.xy, u.cursor_pos);
|
||||
let avoid_start = u.cursor_avoid_radius;
|
||||
let avoid_end = u.cursor_avoid_radius + u.cursor_avoid_falloff;
|
||||
if cursor_dist < avoid_end {
|
||||
let t_avoid = clamp((cursor_dist - avoid_start) / (avoid_end - avoid_start), 0.0, 1.0);
|
||||
// Cursor avoidance — rounded square (box SDF with corner rounding)
|
||||
let cursor_half = vec2f(u.cursor_avoid_radius);
|
||||
let cursor_corner = u.cursor_avoid_radius * 0.3; // 30% rounding smooths the diagonals
|
||||
let cursor_sd = rounded_rect_sdf(pos.xy - u.cursor_pos, cursor_half, cursor_corner);
|
||||
if cursor_sd < u.cursor_avoid_falloff {
|
||||
let t_avoid = clamp(cursor_sd / u.cursor_avoid_falloff, 0.0, 1.0);
|
||||
alpha *= t_avoid * t_avoid * (3.0 - 2.0 * t_avoid);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user