diff options
Diffstat (limited to 'common/shaders/render/scene_query_bvh.wgsl')
| -rw-r--r-- | common/shaders/render/scene_query_bvh.wgsl | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/common/shaders/render/scene_query_bvh.wgsl b/common/shaders/render/scene_query_bvh.wgsl index 3e6f895..cf2136b 100644 --- a/common/shaders/render/scene_query_bvh.wgsl +++ b/common/shaders/render/scene_query_bvh.wgsl @@ -2,25 +2,25 @@ #include "math/sdf_utils" struct BVHNode { - min: vec3<f32>, + min: vec3f, left_idx: i32, - max: vec3<f32>, + max: vec3f, obj_idx_or_right: i32, }; @group(0) @binding(2) var<storage, read> bvh_nodes: array<BVHNode>; -fn get_dist(p: vec3<f32>, obj_params: vec4<f32>) -> f32 { +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, vec3<f32>(1.0)); } // Unit Box - if (obj_type == 3.0) { return sdTorus(p, vec2<f32>(1.0, 0.4)); } // Unit Torus - if (obj_type == 4.0) { return sdPlane(p, vec3<f32>(0.0, 1.0, 0.0), 0.0); } + 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: vec3<f32>, skip_idx: u32) -> f32 { +fn map_scene(p: vec3f, skip_idx: u32) -> f32 { var d = 1000.0; var stack: array<i32, 32>; var stack_ptr = 0; @@ -40,7 +40,7 @@ fn map_scene(p: vec3<f32>, skip_idx: u32) -> f32 { 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 * vec4<f32>(p, 1.0)).xyz; + let q = (obj.inv_model * vec4f(p, 1.0)).xyz; // Extract scale factors from the model matrix let sx = length(obj.model[0].xyz); |
