aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-05-16 21:35:47 +0200
committerladevieq <ladevie.quentin@gmail.com>2021-05-16 21:35:47 +0200
commitb715df2c21dbb8656fc01d5a64605ac18cb5c6e4 (patch)
treecf99f55f9fd4efb647f4c6826648876410f2cfb8 /src
parenta7707f730cd28853dc750b72ec882f07dba85406 (diff)
Wip BVH + BVH debugging tools
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp17
-rw-r--r--src/utils.cpp13
2 files changed, 25 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 071903a..19b7b54 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -103,8 +103,8 @@ int main() {
}
case EVENT_TYPES::KEY_PRESS: {
auto move_speed = 0.01f * delta_time;
- if (wnd.keyboard[KEYS::LSHIFT] || wnd.keyboard[KEYS::RSHIFT]) {
- move_speed *= 2.f;
+ if (wnd.keyboard[KEYS::LSHIFT] || wnd.keyboard[KEYS::RSHIFT] || wnd.keyboard[KEYS::SHIFT]) {
+ move_speed *= 10.f;
}
vec3 move_vec {};
@@ -126,6 +126,14 @@ int main() {
move_vec = -((input_data*) renderer.compute_shader_buffer.alloc_info.pMappedData)->cam.right.unit() * move_speed;
break;
}
+ case KEYS::SPACE: {
+ move_vec = ((input_data*) renderer.compute_shader_buffer.alloc_info.pMappedData)->cam.up.unit() * move_speed;
+ break;
+ }
+ case KEYS::CTRL: {
+ move_vec = -((input_data*) renderer.compute_shader_buffer.alloc_info.pMappedData)->cam.up.unit() * move_speed;
+ break;
+ }
default:
break;
}
@@ -183,6 +191,10 @@ int main() {
ImGui::SliderInt("bounces", (int32_t*)&((input_data*) renderer.compute_shader_buffer.alloc_info.pMappedData)->max_bounce, 2, 250);
+ if (ImGui::Checkbox("debug bvh", (bool*)&((input_data*) renderer.compute_shader_buffer.alloc_info.pMappedData)->debug_bvh)) {
+ reset_accumulation = true;
+ }
+
ImGui::End();
ImGui::EndFrame();
@@ -226,6 +238,7 @@ int main() {
// write_color(std::cout, output_image[index]);
// }
+
std::cerr << "Done !" << std::endl;
return 0;
diff --git a/src/utils.cpp b/src/utils.cpp
index 6467563..bbf8ea4 100644
--- a/src/utils.cpp
+++ b/src/utils.cpp
@@ -106,12 +106,12 @@ uint32_t random_scene(sphere *world) {
material material4 = {};
material4.albedo = color{ 0.0, 0.0, 0.0 };
- material4.emissive = color{ 1.0, 1.0, 1.0 } * 100.0;
+ material4.emissive = color{ 1.0, 1.0, 1.0 } * 100000.0;
material4.fuzz = 0.0;
material4.type = MATERIAL_TYPE::EMISSIVE;
world[world_sphere_index + 3] = { { 2, 1.5, 2 }, material4, 0.5 };
- return world_sphere_index + 3;
+ return world_sphere_index + 4;
}
struct input_data create_inputs(uint32_t width, uint32_t height) {
@@ -141,6 +141,7 @@ struct input_data create_inputs(uint32_t width, uint32_t height) {
.height = height,
.sample_index = 0,
+ .debug_bvh = false,
};
// World hittable objects
@@ -148,7 +149,13 @@ struct input_data create_inputs(uint32_t width, uint32_t height) {
inputs.spheres_count = spheres_count;
- inputs.nodes[0] = { inputs.spheres, 0, spheres_count, inputs.nodes, 1 };
+ bvh builder;
+ builder.build(inputs.spheres, spheres_count);
+ builder.exporter();
+
+ for (uint32_t idx = 0; idx < builder.nodes.size(); idx++) {
+ inputs.nodes[idx] = builder.nodes[idx];
+ }
return inputs;
}