diff --git a/include/ImpostorPage.h b/include/ImpostorPage.h index 3ae5723..70a8e5a 100644 --- a/include/ImpostorPage.h +++ b/include/ImpostorPage.h @@ -162,6 +162,18 @@ namespace Forests /// static const Ogre::ColourValue& getImpostorBackgroundColor() { return s_clrImpostorBackground; } + /** + \brief Sets the material scheme used while rendering the impostor textures. + + This can be used to strip effects that must not be baked into the atlas, + for example fog or wind animation. The default is an empty string, which + leaves the viewport on the default material scheme. + */ + static void setMaterialScheme(const Ogre::String &scheme) { s_materialScheme = scheme; } + + /// + static const Ogre::String& getMaterialScheme() { return s_materialScheme; } + /** \brief Sets the billboard pivot point used when rendering camera-facing impostors @@ -237,6 +249,7 @@ namespace Forests static Ogre::uint s_nSelfInstances; ///< static Ogre::uint s_nUpdateInstanceID; ///< static Ogre::ColourValue s_clrImpostorBackground; ///< + static Ogre::String s_materialScheme; ///< static Ogre::BillboardOrigin s_impostorPivot; ///< }; // end class ImpostorPage diff --git a/source/ImpostorPage.cpp b/source/ImpostorPage.cpp index 32fe6d8..e0e5c1a 100644 --- a/source/ImpostorPage.cpp +++ b/source/ImpostorPage.cpp @@ -35,6 +35,7 @@ Ogre::uint Forests::ImpostorPage::s_nImpostorResolution = 128; Ogre::uint Forests::ImpostorPage::s_nSelfInstances = 0; Ogre::uint Forests::ImpostorPage::s_nUpdateInstanceID = 0; ColourValue Forests::ImpostorPage::s_clrImpostorBackground = ColourValue(0.0f, 0.3f, 0.0f, 0.0f); +String Forests::ImpostorPage::s_materialScheme = ""; BillboardOrigin Forests::ImpostorPage::s_impostorPivot = BBO_CENTER; @@ -429,6 +430,8 @@ void ImpostorTexture::renderTextures(bool force) renderViewport->setClearEveryFrame(true); renderViewport->setShadowsEnabled(false); renderViewport->setBackgroundColour(ImpostorPage::getImpostorBackgroundColor()); + if (!ImpostorPage::getMaterialScheme().empty()) + renderViewport->setMaterialScheme(ImpostorPage::getMaterialScheme()); //Set up scene node SceneNode* node = sceneMgr->getSceneNode("ImpostorPage::renderNode"); @@ -484,7 +487,10 @@ void ImpostorTexture::renderTextures(bool force) //Calculate the filename hash used to uniquely identity this render uint32 key = FastHash(entityKey.c_str(), entityKey.size(), 0); String tempdir = this->group->getParentPagedGeometry()->getTempdir(); - ResourceGroupManager::getSingleton().addResourceLocation(tempdir, "FileSystem", "Impostors"); + //Adding the same location repeatedly creates duplicate archive entries; removing + //one of them then leaves dangling pointers in the resource group index. + if (!ResourceGroupManager::getSingleton().resourceLocationExists(tempdir, "Impostors")) + ResourceGroupManager::getSingleton().addResourceLocation(tempdir, "FileSystem", "Impostors"); String fileName = StringUtil::format("Impostor.%08X.%d", key, textureSize);