add ability to set the type of near far method to be used in shadow calculation; default to bounding volumes; cleaned up code while there and re-ordered items

This commit is contained in:
Bret Curtis 2020-04-29 11:46:52 +02:00
parent 476a74c2d3
commit ae729a1ac7
6 changed files with 131 additions and 94 deletions

View file

@ -2,6 +2,7 @@
#include <osgShadow/ShadowedScene>
#include <components/misc/stringops.hpp>
#include <components/settings/settings.hpp>
namespace SceneUtil
@ -38,11 +39,14 @@ namespace SceneUtil
}
mShadowSettings->setMinimumShadowMapNearFarRatio(Settings::Manager::getFloat("minimum lispsm near far ratio", "Shadows"));
if (Settings::Manager::getBool("compute tight scene bounds", "Shadows"))
std::string computeNearFarMode = Settings::Manager::getString("near far computation", "Shadows");
if (Misc::StringUtils::lowerCase(computeNearFarMode) == "primitives")
mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_PRIMITIVES);
else
else if (Misc::StringUtils::lowerCase(computeNearFarMode) == "bounding volumes")
mShadowSettings->setComputeNearFarModeOverride(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows");
mShadowSettings->setTextureSize(osg::Vec2s(mapres, mapres));