From 73bb4462b59c104b74c9fc48da6b682bf14427b8 Mon Sep 17 00:00:00 2001 From: TheRedShip Date: Mon, 20 Jan 2025 12:14:53 +0100 Subject: [PATCH] + | Compute bvhdata patch --- scenes/dragon.rt | 9 +++++++-- shaders/trace.glsl | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/scenes/dragon.rt b/scenes/dragon.rt index 307edae..929cdf4 100644 --- a/scenes/dragon.rt +++ b/scenes/dragon.rt @@ -25,7 +25,12 @@ pl 0 -2 0 0 1 0 2 // floor qu -1 1.999 -1 2 0 0 0 0 2 6 OBJ obj/Dragon_80K.obj +# OBJ obj/Dragon_80K.obj +# OBJ obj/teapot.obj + +# OBJ obj/Model.obj + # OBJ obj/Lowpoly_tree_sample.obj -# po -1.99 -0.5 -0.5 0 1 0 0 0 1 1 4 -# po -0.5 -0.5 -1.99 0 1 0 1 0 0 0 4 +po -1.99 -0.5 -0.5 0 1 0 0 0 1 1 4 +po -0.5 -0.5 -1.99 0 1 0 1 0 0 0 4 diff --git a/shaders/trace.glsl b/shaders/trace.glsl index 9f2d0a0..c4befa1 100644 --- a/shaders/trace.glsl +++ b/shaders/trace.glsl @@ -127,8 +127,10 @@ hitInfo traverseBVHs(Ray ray) for (int i = 0; i < u_bvhNum; i++) { - ray.origin = i == 0 ? ray.origin : ray.origin + vec3(2., 0., 0.); - hitInfo temp_hit = traceBVH(ray, BvhData[i]); + GPUBvhData bvh_data = BvhData[i]; + + ray.origin = ray.origin + vec3(float(i), 0., 0.); + hitInfo temp_hit = traceBVH(ray, bvh_data); if (temp_hit.t < hit.t) { @@ -156,7 +158,7 @@ hitInfo traceRay(Ray ray) hitScene = traceScene(ray); hit = hitBVH.t < hitScene.t ? hitBVH : hitScene; - #if 0 + #if 1 if (hit.obj_index == -1 || objects[hit.obj_index].type != 5) break ; ray = portalRay(ray, hit);