From 6c71334cdac01d82710494c7b247b69fa5f1c099 Mon Sep 17 00:00:00 2001 From: vlj Date: Mon, 4 Aug 2014 01:12:45 +0200 Subject: [PATCH] Only calculate diffuse coefficient once. --- src/graphics/irr_driver.cpp | 2 ++ src/graphics/irr_driver.hpp | 1 + src/graphics/render_skybox.cpp | 3 +++ 3 files changed, 6 insertions(+) diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 6fde23249..6808684f1 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -1204,6 +1204,7 @@ scene::ISceneNode *IrrDriver::addSkyBox(const std::vector &tex SkyboxTextures = texture; SphericalHarmonicsTextures = sphericalHarmonics; SkyboxCubeMap = 0; + m_SH_dirty = true; return m_scene_manager->addSkyBoxSceneNode(texture[0], texture[1], texture[2], texture[3], texture[4], texture[5]); @@ -1213,6 +1214,7 @@ void IrrDriver::suppressSkyBox() { SkyboxTextures.clear(); SphericalHarmonicsTextures.clear(); + m_SH_dirty = true; if ((SkyboxCubeMap) && (!ProfileWorld::isNoGraphics())) glDeleteTextures(1, &SkyboxCubeMap); SkyboxCubeMap = 0; diff --git a/src/graphics/irr_driver.hpp b/src/graphics/irr_driver.hpp index b41190555..8118f0948 100644 --- a/src/graphics/irr_driver.hpp +++ b/src/graphics/irr_driver.hpp @@ -233,6 +233,7 @@ private: std::vector SkyboxTextures; std::vector SphericalHarmonicsTextures; + bool m_SH_dirty; float blueSHCoeff[9]; float greenSHCoeff[9]; diff --git a/src/graphics/render_skybox.cpp b/src/graphics/render_skybox.cpp index ec9e4720d..599251fac 100644 --- a/src/graphics/render_skybox.cpp +++ b/src/graphics/render_skybox.cpp @@ -437,6 +437,9 @@ void IrrDriver::generateSkyboxCubemap() void IrrDriver::generateDiffuseCoefficients() { + if (!m_SH_dirty) + return; + m_SH_dirty = false; const unsigned texture_permutation[] = { 2, 3, 0, 1, 5, 4 }; if (SphericalHarmonicsTextures.size() == 6)