Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions include/ImpostorPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
8 changes: 7 additions & 1 deletion source/ImpostorPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;


Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);

Expand Down
Loading