+ | Fog imGUI

This commit is contained in:
TheRedShip
2025-01-14 20:38:03 +01:00
parent 95098711f7
commit 2899055b51
9 changed files with 103 additions and 36 deletions

View File

@ -15,6 +15,12 @@
Scene::Scene()
{
_camera = new Camera(glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3(0.0f, 1.0f, 0.0f), -90.0f, 0.0f);
_gpu_volume.enabled = false;
_gpu_volume.sigma_a = glm::vec3(0.0001f);
_gpu_volume.sigma_s = glm::vec3(0.0800f);
_gpu_volume.sigma_t = _gpu_volume.sigma_a + _gpu_volume.sigma_s;
_gpu_volume.g = 0.9f;
}
Scene::~Scene()
@ -143,6 +149,11 @@ std::vector<GPUMaterial>& Scene::getMaterialData()
return (_gpu_materials);
}
GPUVolume &Scene::getVolume()
{
return (_gpu_volume);
}
Camera *Scene::getCamera(void) const
{
return (_camera);

View File

@ -215,6 +215,29 @@ void Window::imGuiRender()
ImGui::End();
ImGui::Begin("Fog settings");
has_changed |= ImGui::Checkbox("Enable", &_scene->getVolume().enabled);
ImGui::Separator();
if (ImGui::SliderFloat("Absorption", &_scene->getVolume().sigma_a.x, 0., 0.1))
{
_scene->getVolume().sigma_a = glm::vec3(_scene->getVolume().sigma_a.x);
_scene->getVolume().sigma_t = _scene->getVolume().sigma_a + _scene->getVolume().sigma_s;
has_changed = true;
}
if (ImGui::SliderFloat("Scattering", &_scene->getVolume().sigma_s.x, 0., 0.5))
{
_scene->getVolume().sigma_s = glm::vec3(_scene->getVolume().sigma_s.x);
_scene->getVolume().sigma_t = _scene->getVolume().sigma_a + _scene->getVolume().sigma_s;
has_changed = true;
}
if (ImGui::SliderFloat("G", &_scene->getVolume().g, 0., 1.))
has_changed = true;
ImGui::End();
ImGui::Render();
ImGui_ImplOpenGL3_RenderDrawData(ImGui::GetDrawData());