Skip to content
Merged
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
19 changes: 19 additions & 0 deletions ogre2/src/Ogre2RenderTarget.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,24 @@ void Ogre2RenderTarget::UpdateShadowNode()
}
}

// limit number of shadow maps
// shaders dynamically generated by ogre produce compile error at runtime if
// the number of shadow maps exceeds certain number. The error seems to
// suggest that the number of uniform variables has exceeded the max number
// allowed
unsigned int maxShadowMaps = 25u;
if (dirLightCount * 3 + spotPointLightCount > maxShadowMaps)
{
dirLightCount = std::min(static_cast<unsigned int>(maxShadowMaps / 3),
dirLightCount);
spotPointLightCount = std::min(
std::max(maxShadowMaps - dirLightCount * 3, 0u), spotPointLightCount);
ignwarn << "Number of shadow-casting lights exceeds the limit supported by "
<< "the underlying rendering engine ogre2. Limiting to "
<< dirLightCount << " directional lights and "
<< spotPointLightCount << " point / spot lights" << std::endl;
}

auto engine = Ogre2RenderEngine::Instance();
Ogre::CompositorManager2 *compositorManager =
engine->OgreRoot()->getCompositorManager2();
Expand Down Expand Up @@ -386,6 +404,7 @@ void Ogre2RenderTarget::UpdateShadowNode()
unsigned int colIdx = 0;
unsigned int rowSize = maxTexSize / texSize;
unsigned int colSize = rowSize;

for (unsigned int i = 0; i < spotPointLightCount; ++i)
{
shadowParam.technique = Ogre::SHADOWMAP_FOCUSED;
Expand Down