From d67706c18c6ec8d6144e734b2b5a7af7348e4a90 Mon Sep 17 00:00:00 2001 From: Anselme Date: Mon, 16 Oct 2017 17:06:39 +0200 Subject: [PATCH] added lightenv class, used to store the environment lighting parameters --- src/lighingenv.cpp | 25 +++++++++++++++++++++++++ src/lighingenv.h | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 src/lighingenv.cpp create mode 100644 src/lighingenv.h diff --git a/src/lighingenv.cpp b/src/lighingenv.cpp new file mode 100644 index 0000000..e3abd52 --- /dev/null +++ b/src/lighingenv.cpp @@ -0,0 +1,25 @@ +#include "lighingenv.h" +#include "imgui/imgui.h" +#include "texture.h" +#include + +LighingEnv::LighingEnv() +{ + +} + +void LighingEnv::gui() +{ + ImGui::Checkbox("Fog", &m_hasFog); + if(m_hasFog) + { + ImGui::SliderFloat("Fog density", &m_fogDensity, 0, 10000, "%.3f", 10.f); + ImGui::ColorEdit3("Fog color", glm::value_ptr(m_fogColor)); + ImGui::Checkbox("Ground fog", &m_isGroundFog); + if(m_isGroundFog) + { + ImGui::SliderFloat("Ground fog floor", &m_fogFloor, -1000, 1000); + ImGui::SliderFloat("Ground fog ceiling", &m_fogCeiling, -1000, 1000); + } + } +} diff --git a/src/lighingenv.h b/src/lighingenv.h new file mode 100644 index 0000000..41797d9 --- /dev/null +++ b/src/lighingenv.h @@ -0,0 +1,45 @@ +#ifndef LIGHINGENV_H +#define LIGHINGENV_H + +#include + +class Texture; + +class LighingEnv +{ + Texture* m_radianceMap; + Texture* m_irradianceMap; + + bool m_hasFog; + float m_fogDensity; + glm::vec3 m_fogColor; + + bool m_isGroundFog; + float m_fogFloor; + float m_fogCeiling; + +public: + LighingEnv(); + + // environment mapping methods + + void setRadianceMap(Texture* tex); // used for the specular component + void setIrradianceMap(Texture* tex); // used for the diffuse component + + // fog methods + + void setNoFog() { m_hasFog = false; } + + void setUniformFog(float fogDensity, glm::vec3 fogColor) + { m_hasFog = true; m_fogDensity = fogDensity; m_fogColor = fogColor; } + + void setGroundFog(float fogDensity, glm::vec3 fogColor, float fogFloor, float fogCeiling) + { setUniformFog(fogDensity, fogColor); m_isGroundFog = true; m_fogFloor = fogFloor; m_fogCeiling = fogCeiling; } + + /** + * @brief this gui does not include the begin/end calls, only the fog editor + */ + void gui(); +}; + +#endif // LIGHINGENV_H