summaryrefslogtreecommitdiff
path: root/common/shaders/render/shadows.wgsl
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-13 08:34:24 +0100
committerskal <pascal.massimino@gmail.com>2026-02-13 08:34:24 +0100
commita109983c194c45ad85f0e481232bc605c7cfd85b (patch)
tree2b2fadb054fb8ea52d3e31fefdc4678d5a3ed7dc /common/shaders/render/shadows.wgsl
parent3ce45fcf073047d71ed0b2c88f4d6c5362f6b620 (diff)
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
Diffstat (limited to 'common/shaders/render/shadows.wgsl')
-rw-r--r--common/shaders/render/shadows.wgsl13
1 files changed, 13 insertions, 0 deletions
diff --git a/common/shaders/render/shadows.wgsl b/common/shaders/render/shadows.wgsl
new file mode 100644
index 0000000..7cba089
--- /dev/null
+++ b/common/shaders/render/shadows.wgsl
@@ -0,0 +1,13 @@
+fn calc_shadow(ro: vec3<f32>, rd: vec3<f32>, tmin: f32, tmax: f32, skip_idx: u32) -> f32 {
+ var res = 1.0;
+ var t = tmin;
+ if (t < 0.05) { t = 0.05; }
+ for (var i = 0; i < 32; i = i + 1) {
+ let h = map_scene(ro + rd * t, skip_idx);
+ if (h < 0.001) { return 0.0; }
+ res = min(res, 16.0 * h / t);
+ t = t + clamp(h, 0.02, 0.4);
+ if (t > tmax) { break; }
+ }
+ return clamp(res, 0.0, 1.0);
+}