From a109983c194c45ad85f0e481232bc605c7cfd85b Mon Sep 17 00:00:00 2001 From: skal Date: Fri, 13 Feb 2026 08:34:24 +0100 Subject: Remediation: Implement shared common/shaders/ directory Eliminates 36 duplicate shader files across workspaces. Structure: - common/shaders/{math,render,compute}/ - Shared utilities (20 files) - workspaces/*/shaders/ - Workspace-specific only Changes: - Created common/shaders/ with math, render, compute subdirectories - Moved 20 common shaders from workspaces to common/ - Removed duplicates from test workspace - Updated assets.txt: ../../common/shaders/ references - Enhanced asset_packer.cc: filesystem path normalization for ../ resolution Implementation: Option 1 from SHADER_REUSE_INVESTIGATION.md - Single source of truth for common code - Workspace references via relative paths - Path normalization in asset packer handoff(Claude): Common shader directory implemented --- common/shaders/math/sdf_shapes.wgsl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 common/shaders/math/sdf_shapes.wgsl (limited to 'common/shaders/math/sdf_shapes.wgsl') diff --git a/common/shaders/math/sdf_shapes.wgsl b/common/shaders/math/sdf_shapes.wgsl new file mode 100644 index 0000000..31bbe2d --- /dev/null +++ b/common/shaders/math/sdf_shapes.wgsl @@ -0,0 +1,14 @@ +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; +} -- cgit v1.2.3