summaryrefslogtreecommitdiff
path: root/common/shaders/render/scene_query_bvh.wgsl
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-28 09:08:57 +0100
committerskal <pascal.massimino@gmail.com>2026-02-28 09:08:57 +0100
commit9ee410594a52cbc699b13de2bde4860d70c959a3 (patch)
treed56adf5931d488abcf3ac8e24a828d2d5b02e8cc /common/shaders/render/scene_query_bvh.wgsl
parent6599a428cd69be6c66c5179e1f0fce42f561f935 (diff)
refactor: move common/shaders/ to src/shaders/
Relocates shared WGSL shaders under src/ where all source code lives, eliminating the top-level common/ directory. - Update asset references in workspaces/main/assets.txt and workspaces/test/assets.txt - Update docs: PROJECT_CONTEXT.md, ARCHITECTURE.md, WORKSPACE_SYSTEM.md, SHADER_REUSE_INVESTIGATION.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'common/shaders/render/scene_query_bvh.wgsl')
-rw-r--r--common/shaders/render/scene_query_bvh.wgsl67
1 files changed, 0 insertions, 67 deletions
diff --git a/common/shaders/render/scene_query_bvh.wgsl b/common/shaders/render/scene_query_bvh.wgsl
deleted file mode 100644
index cf2136b..0000000
--- a/common/shaders/render/scene_query_bvh.wgsl
+++ /dev/null
@@ -1,67 +0,0 @@
-#include "math/sdf_shapes"
-#include "math/sdf_utils"
-
-struct BVHNode {
- min: vec3f,
- left_idx: i32,
- max: vec3f,
- obj_idx_or_right: i32,
-};
-
-@group(0) @binding(2) var<storage, read> bvh_nodes: array<BVHNode>;
-
-fn get_dist(p: vec3f, obj_params: vec4f) -> f32 {
- let obj_type = obj_params.x;
- if (obj_type == 1.0) { return length(p) - 1.0; } // Unit Sphere
- if (obj_type == 2.0) { return sdBox(p, vec3f(1.0)); } // Unit Box
- if (obj_type == 3.0) { return sdTorus(p, vec2f(1.0, 0.4)); } // Unit Torus
- if (obj_type == 4.0) { return sdPlane(p, vec3f(0.0, 1.0, 0.0), 0.0); }
- if (obj_type == 5.0) { return sdBox(p, obj_params.yzw); } // MESH AABB
- return 100.0;
-}
-
-fn map_scene(p: vec3f, skip_idx: u32) -> f32 {
- var d = 1000.0;
- var stack: array<i32, 32>;
- var stack_ptr = 0;
-
- if (arrayLength(&bvh_nodes) > 0u) {
- stack[stack_ptr] = 0;
- stack_ptr++;
- }
-
- while (stack_ptr > 0) {
- stack_ptr--;
- let node_idx = stack[stack_ptr];
- let node = bvh_nodes[node_idx];
-
- if (aabb_sdf(p, node.min, node.max) < d) {
- if (node.left_idx < 0) { // Leaf
- let obj_idx = u32(node.obj_idx_or_right);
- if (obj_idx == skip_idx) { continue; }
- let obj = object_data.objects[obj_idx];
- let q = (obj.inv_model * vec4f(p, 1.0)).xyz;
-
- // Extract scale factors from the model matrix
- let sx = length(obj.model[0].xyz);
- let sy = length(obj.model[1].xyz);
- let sz = length(obj.model[2].xyz);
-
- var s = min(sx, min(sy, sz));
- if (obj.params.x == 4.0) {
- s = sy; // Plane normal is (0,1,0) in local space
- }
-
- d = min(d, get_dist(q, obj.params) * s);
- } else { // Internal
- if (stack_ptr < 31) {
- stack[stack_ptr] = node.left_idx;
- stack_ptr++;
- stack[stack_ptr] = node.obj_idx_or_right;
- stack_ptr++;
- }
- }
- }
- }
- return d;
-}