From 2c8002d30f291cba832a5750212009d48238c308 Mon Sep 17 00:00:00 2001 From: hachem Date: Fri, 22 Aug 2025 12:24:05 +0200 Subject: feat: add HDRI --- src/states/simulation_state.cpp | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'src/states/simulation_state.cpp') diff --git a/src/states/simulation_state.cpp b/src/states/simulation_state.cpp index 9f1e0a7..540f236 100644 --- a/src/states/simulation_state.cpp +++ b/src/states/simulation_state.cpp @@ -1,6 +1,7 @@ #include "simulation_state.h" #include "rendering/renderer.h" #include "core/application.h" +#include "core/hdri_manager.h" #include "core/window.h" #include "core/event.h" #include "core/settings_manager.h" @@ -10,6 +11,7 @@ #include #include #include +#include namespace Donut { @@ -165,9 +167,7 @@ namespace Donut ImGui::Text("Objects: %zu", engine.get_objects().size()); if (ImGui::Button("Print Object Info")) - { engine.print_object_info(); - } int compute_height = engine.get_compute_height(); if (ImGui::SliderInt("Compute Height", &compute_height, 64, 2048)) @@ -281,6 +281,40 @@ namespace Donut ImGui::Spacing(); + ImGui::TextColored(ImVec4(0.9f, 0.9f, 1.0f, 1.0f), "HDRI Environment"); + ImGui::Separator(); + + static int selected_hdri = 0; + ImGui::PushID("SimulationHDRI"); + auto& hdri_manager = HDRIManager::get(); + const auto& available_hdri = hdri_manager.get_available_hdri(); + + static std::vector hdri_option_names; + static std::vector hdri_options; + + if (hdri_option_names.size() != available_hdri.size()) + { + hdri_option_names.clear(); + hdri_options.clear(); + + for (const auto& path : available_hdri) + { + hdri_option_names.push_back(hdri_manager.get_hdri_name(path)); + hdri_options.push_back(hdri_option_names.back().c_str()); + } + } + + if (ImGui::Combo("HDRI Environment", &selected_hdri, hdri_options.data(), static_cast(hdri_options.size()))) + { + auto& hdri_manager = HDRIManager::get(); + hdri_manager.set_current_hdri(available_hdri[selected_hdri]); + engine.set_hdri_environment(hdri_manager.get_current_hdri()); + } + ImGui::TextDisabled("HDRI provides background and lighting for the simulation"); + ImGui::PopID(); + + ImGui::Spacing(); + ImGui::TextColored(ImVec4(0.9f, 0.9f, 1.0f, 1.0f), "Camera"); ImGui::Separator(); -- cgit v1.3