1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 13:41:32 +00:00

Make split point control parameters configurable with the new shadow technique.

This commit is contained in:
AnyOldName3 2018-02-26 23:00:46 +00:00
parent e233dae1cd
commit 882b63cba9
3 changed files with 22 additions and 4 deletions

View file

@ -767,6 +767,16 @@ void SceneUtil::MWShadowTechnique::disableDebugHUD()
_debugHud = nullptr; _debugHud = nullptr;
} }
void SceneUtil::MWShadowTechnique::setSplitPointUniformLogarithmicRatio(double ratio)
{
_splitPointUniformLogRatio = ratio;
}
void SceneUtil::MWShadowTechnique::setSplitPointDeltaBias(double bias)
{
_splitPointDeltaBias = bias;
}
MWShadowTechnique::ViewDependentData* MWShadowTechnique::createViewDependentData(osgUtil::CullVisitor* /*cv*/) MWShadowTechnique::ViewDependentData* MWShadowTechnique::createViewDependentData(osgUtil::CullVisitor* /*cv*/)
{ {
return new ViewDependentData(this); return new ViewDependentData(this);
@ -1096,8 +1106,6 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
double f = reducedFar; double f = reducedFar;
double i = double(sm_i); double i = double(sm_i);
double m = double(numShadowMapsPerLight); double m = double(numShadowMapsPerLight);
double ratio = 0.5; // TODO: Settings::Manager::getFloat("split point uniform logarithmic ratio", "Shadows");
double deltaBias = 0.0; // TODO: Settings::Manager::getFloat("split point bias", "Shadows");
if (sm_i == 0) if (sm_i == 0)
r_start = -1.0; r_start = -1.0;
else else
@ -1105,7 +1113,7 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
// compute the split point in main camera view // compute the split point in main camera view
double ciLog = n * pow(f / n, i / m); double ciLog = n * pow(f / n, i / m);
double ciUniform = n + (f - n) * i / m; double ciUniform = n + (f - n) * i / m;
double ci = ratio * ciLog + (1.0 - ratio) * ciUniform + deltaBias; double ci = _splitPointUniformLogRatio * ciLog + (1.0 - _splitPointUniformLogRatio) * ciUniform + _splitPointDeltaBias;
// work out where this is in light space // work out where this is in light space
osg::Vec3d worldSpacePos = frustum.eye + frustum.frustumCenterLine * ci; osg::Vec3d worldSpacePos = frustum.eye + frustum.frustumCenterLine * ci;
@ -1120,7 +1128,7 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv)
// compute the split point in main camera view // compute the split point in main camera view
double ciLog = n * pow(f / n, (i + 1) / m); double ciLog = n * pow(f / n, (i + 1) / m);
double ciUniform = n + (f - n) * (i + 1) / m; double ciUniform = n + (f - n) * (i + 1) / m;
double ci = ratio * ciLog + (1.0 - ratio) * ciUniform + deltaBias; double ci = _splitPointUniformLogRatio * ciLog + (1.0 - _splitPointUniformLogRatio) * ciUniform + _splitPointDeltaBias;
// work out where this is in light space // work out where this is in light space
osg::Vec3d worldSpacePos = frustum.eye + frustum.frustumCenterLine * ci; osg::Vec3d worldSpacePos = frustum.eye + frustum.frustumCenterLine * ci;

View file

@ -69,6 +69,10 @@ namespace SceneUtil {
virtual void disableDebugHUD(); virtual void disableDebugHUD();
virtual void setSplitPointUniformLogarithmicRatio(double ratio);
virtual void setSplitPointDeltaBias(double bias);
class ComputeLightSpaceBounds : public osg::NodeVisitor, public osg::CullStack class ComputeLightSpaceBounds : public osg::NodeVisitor, public osg::CullStack
{ {
public: public:
@ -232,6 +236,9 @@ namespace SceneUtil {
bool _enableShadows; bool _enableShadows;
double _splitPointUniformLogRatio = 0.5;
double _splitPointDeltaBias = 0.0;
class DebugHUD : public osg::Referenced class DebugHUD : public osg::Referenced
{ {
public: public:

View file

@ -40,6 +40,9 @@ namespace SceneUtil
int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows"); int mapres = Settings::Manager::getInt("shadow map resolution", "Shadows");
settings->setTextureSize(osg::Vec2s(mapres, mapres)); settings->setTextureSize(osg::Vec2s(mapres, mapres));
mShadowTechnique->setSplitPointUniformLogarithmicRatio(Settings::Manager::getFloat("split point uniform logarithmic ratio", "Shadows"));
mShadowTechnique->setSplitPointDeltaBias(Settings::Manager::getFloat("split point bias", "Shadows"));
if (Settings::Manager::getBool("enable debug hud", "Shadows")) if (Settings::Manager::getBool("enable debug hud", "Shadows"))
mShadowTechnique->enableDebugHUD(); mShadowTechnique->enableDebugHUD();
else else