From 2cadf6af94e5622706e2958e7eb1634b44939338 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 31 Oct 2026 16:10:02 +0100 Subject: [PATCH 1/2] ImpostorPage: only add the impostor directory once Adding the same resource location on every render creates duplicate archive entries; removing one of them then leaves dangling pointers in the resource group index. Check whether the location is already registered before adding it. --- source/ImpostorPage.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/ImpostorPage.cpp b/source/ImpostorPage.cpp index 32fe6d8..4e0d84f 100644 --- a/source/ImpostorPage.cpp +++ b/source/ImpostorPage.cpp @@ -484,7 +484,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); From 4bf33981bd7f5916542a83fa74e374c381bd0b91 Mon Sep 17 00:00:00 2001 From: Pavel Rojtberg Date: Sat, 31 Oct 2026 14:20:37 +0100 Subject: [PATCH 2/2] ImpostorPage: allow selecting a material scheme for the atlas RTT Rendering the atlas with the default material scheme bakes effects such as fog, shadows and wind into the texture, leaving fog-coloured fringes around distant vegetation. Allow applications to select a material scheme for the impostor rendering viewport so they can strip those effects. The default is an empty string, which leaves the viewport on the default material scheme. --- include/ImpostorPage.h | 13 +++++++++++++ source/ImpostorPage.cpp | 3 +++ 2 files changed, 16 insertions(+) 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 4e0d84f..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");