From 0127c747a41f972fd68e3e6e6b472859bfdb80dd Mon Sep 17 00:00:00 2001 From: skal Date: Sat, 14 Feb 2026 15:26:55 +0100 Subject: refactor(wgsl): consolidate SDF shapes into single common file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Merge sdf_primitives.wgsl into math/sdf_shapes.wgsl to eliminate duplication and establish single source of truth for all SDF functions. Changes: - Delete common/shaders/sdf_primitives.wgsl (duplicate of math/sdf_shapes.wgsl) - Add sdBox2D() and sdEllipse() to math/sdf_shapes.wgsl - Update ellipse.wgsl (main/test) to use #include "math/sdf_shapes" - Update scene1.wgsl to use math/sdf_shapes instead of sdf_primitives - Rename asset SHADER_SDF_PRIMITIVES → SHADER_SDF_SHAPES - Update shader registration and tests Impact: - ~60 lines eliminated from ellipse shaders - Single source for 3D primitives (sphere, box, torus, plane) and 2D (box, ellipse) - Consistent include path across codebase All tests passing (34/34). handoff(Claude): SDF shapes consolidated to math/sdf_shapes.wgsl Co-Authored-By: Claude Sonnet 4.5 --- common/shaders/sdf_primitives.wgsl | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 common/shaders/sdf_primitives.wgsl (limited to 'common/shaders/sdf_primitives.wgsl') diff --git a/common/shaders/sdf_primitives.wgsl b/common/shaders/sdf_primitives.wgsl deleted file mode 100644 index 407fb29..0000000 --- a/common/shaders/sdf_primitives.wgsl +++ /dev/null @@ -1,19 +0,0 @@ -fn sdSphere(p: vec3, r: f32) -> f32 { - return length(p) - r; -} -fn sdBox(p: vec3, b: vec3) -> f32 { - let q = abs(p) - b; - return length(max(q, vec3(0.0))) + min(max(q.x, max(q.y, q.z)), 0.0); -} -fn sdTorus(p: vec3, t: vec2) -> f32 { - let q = vec2(length(p.xz) - t.x, p.y); - return length(q) - t.y; -} -fn sdPlane(p: vec3, n: vec3, h: f32) -> f32 { - return dot(p, n) + h; -} - -fn sdBox2D(p: vec2, b: vec2) -> f32 { - let d = abs(p) - b; - return length(max(d, vec2(0.0))) + min(max(d.x, d.y), 0.0); -} -- cgit v1.2.3