From d6d532988a87667d6877e21401db9fcdae154db5 Mon Sep 17 00:00:00 2001 From: Devashish Lal Date: Mon, 24 Jun 2024 16:11:12 -0700 Subject: [PATCH] hit_sphere test Signed-off-by: Devashish Lal --- webray/src/shaders/webray.wgsl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/webray/src/shaders/webray.wgsl b/webray/src/shaders/webray.wgsl index 944dbdd..26d105e 100644 --- a/webray/src/shaders/webray.wgsl +++ b/webray/src/shaders/webray.wgsl @@ -6,7 +6,7 @@ const ERR_COLOR = vec3f(1.0, 0.0, 1.0); // UTILS_START fn vec3f_len_squared(v: vec3f) -> f32 { - return v.x * v.x + v.y * v.y + v.z * v.z; + return (v.x * v.x) + (v.y * v.y) + (v.z * v.z); } fn vec3f_near_zero(v: vec3f) -> bool { @@ -301,10 +301,10 @@ fn hit_sphere(sphere: Sphere, ray: Ray, ray_limits: Interval, hit: ptr) -> var closest_so_far = ray_limits.max; // arrayLength returns a u32, so we make i also u32 to make logical operation happy - for (var i = 0u; i < 5u; i++) { + for (var i = 0u; i < arrayLength(&spheres); i++) { let sphere = spheres[i]; if hit_sphere(sphere, ray, Interval(ray_limits.min, closest_so_far), &temp_hit) { @@ -390,7 +390,7 @@ fn render_ray(ray: Ray) -> vec3f { } // number of bounce visualization - // accumulated_color = vec3f(1.0, 1.0, 1.0) / f32(bounce + 1); + accumulated_color = vec3f(1.0, 1.0, 1.0) / f32(bounce + 1); // max bounce condition if bounce >= config.image.bounces {