diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 4767794d7..f964512a5 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -1621,15 +1621,17 @@ void IrrDriver::onUnloadWorld() /** Sets the ambient light. * \param light The colour of the light to set. */ -void IrrDriver::setAmbientLight(const video::SColor &light) +void IrrDriver::setAmbientLight(const video::SColorf &light) { + printf("redval %f\n", light.getRed()); m_scene_manager->setAmbientLight(light); + m_ambient = light; m_SH_dirty = true; } // setAmbientLight video::SColorf IrrDriver::getAmbientLight() const { - return m_scene_manager->getAmbientLight(); + return m_ambient; } // ---------------------------------------------------------------------------- diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index ec358cf2a..ba269eb76 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -341,6 +341,7 @@ private: std::vector m_forcedbloom; std::vector m_background; + video::SColorf m_ambient; STKRenderingPass m_phase; @@ -391,7 +392,7 @@ public: const std::string& mask_path); void displayFPS(); bool OnEvent(const irr::SEvent &event); - void setAmbientLight(const video::SColor &light); + void setAmbientLight(const video::SColorf &light); std::string generateSmallerTextures(const std::string& dir); std::string getSmallerTexture(const std::string& texture); video::ITexture *getTexture(FileManager::AssetType type, diff --git a/src/graphics/render_skybox.cpp b/src/graphics/render_skybox.cpp index 17d8014b6..1460570e7 100644 --- a/src/graphics/render_skybox.cpp +++ b/src/graphics/render_skybox.cpp @@ -485,8 +485,7 @@ void IrrDriver::generateDiffuseCoefficients() int sh_w = 16; int sh_h = 16; - const video::SColorf& ambientf = irr_driver->getSceneManager()->getAmbientLight(); - video::SColor ambient = ambientf.toSColor(); + video::SColor ambient = m_ambient.toSColor(); unsigned char *sh_rgba[6]; for (unsigned i = 0; i < 6; i++) diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index 18c71d5fe..144bf77d4 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -444,8 +444,8 @@ bool onEvent(const SEvent &event) { new DebugSliderDialog("Red", "Red", [](){ return irr_driver->getAmbientLight().r * 255.; }, [](int v){ - video::SColor ambient = irr_driver->getAmbientLight().toSColor(); - ambient.setRed(v); + video::SColorf ambient = irr_driver->getAmbientLight(); + ambient.setColorComponentValue(0, v / 255.); irr_driver->setAmbientLight(ambient); } ); } @@ -453,8 +453,8 @@ bool onEvent(const SEvent &event) { new DebugSliderDialog("Green", "Green", [](){ return irr_driver->getAmbientLight().g * 255.; }, [](int v){ - video::SColor ambient = irr_driver->getAmbientLight().toSColor(); - ambient.setGreen(v); + video::SColorf ambient = irr_driver->getAmbientLight(); + ambient.setColorComponentValue(1, v / 255.); irr_driver->setAmbientLight(ambient); } ); } @@ -462,8 +462,8 @@ bool onEvent(const SEvent &event) { new DebugSliderDialog("Blue", "Blue", [](){ return irr_driver->getAmbientLight().b * 255.; }, [](int v){ - video::SColor ambient = irr_driver->getAmbientLight().toSColor(); - ambient.setBlue(v); + video::SColorf ambient = irr_driver->getAmbientLight(); + ambient.setColorComponentValue(2, v / 255.); irr_driver->setAmbientLight(ambient); } ); }