From 1b30d47d7f79fdcba463241df0c683f7b44fad69 Mon Sep 17 00:00:00 2001 From: AnyOldName3 Date: Sun, 13 May 2018 12:56:40 +0100 Subject: [PATCH] Add a hacky temporary version of cascading shadow maps --- components/sceneutil/mwshadowtechnique.cpp | 29 +++++++++++++++------- components/sceneutil/mwshadowtechnique.hpp | 2 +- 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/components/sceneutil/mwshadowtechnique.cpp b/components/sceneutil/mwshadowtechnique.cpp index db0788318..d2c4c3a8f 100644 --- a/components/sceneutil/mwshadowtechnique.cpp +++ b/components/sceneutil/mwshadowtechnique.cpp @@ -149,7 +149,7 @@ std::string debugFrustumFragmentShaderSource = " \n" " gl_FragColor = vec4( fS + fH * color, 1 ); \n" #else - " gl_FragColor = texture2D(texture, gl_TexCoord[0].xy); \n" + " gl_FragColor = vec4(0.0, 0.0, 1.0, 0.0); \n" #endif "} \n"; @@ -1130,7 +1130,8 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv) osg::Polytope local_polytope(polytope); local_polytope.transformProvidingInverse(invertModelView); - + double cascaseNear = reducedNear; + double cascadeFar = reducedFar; if (numShadowMapsPerLight>1) { // compute the start and end range in non-dimensional coords @@ -1158,6 +1159,7 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv) double ciLog = n * pow(f / n, i / m); double ciUniform = n + (f - n) * i / m; double ci = _splitPointUniformLogRatio * ciLog + (1.0 - _splitPointUniformLogRatio) * ciUniform + _splitPointDeltaBias; + cascaseNear = ci; // work out where this is in light space osg::Vec3d worldSpacePos = frustum.eye + frustum.frustumCenterLine * ci; @@ -1173,7 +1175,8 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv) double ciLog = n * pow(f / n, (i + 1) / m); double ciUniform = n + (f - n) * (i + 1) / m; double ci = _splitPointUniformLogRatio * ciLog + (1.0 - _splitPointUniformLogRatio) * ciUniform + _splitPointDeltaBias; - + cascadeFar = ci; + // work out where this is in light space osg::Vec3d worldSpacePos = frustum.eye + frustum.frustumCenterLine * ci; osg::Vec3d lightSpacePos = worldSpacePos * viewMatrix * projectionMatrix; @@ -1185,7 +1188,7 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv) if (sm_i+10) + if (false)//(sm_i>0) { // not the first shadowmap so insert a polytope to clip the scene from before r_start @@ -1200,7 +1203,7 @@ void MWShadowTechnique::cull(osgUtil::CullVisitor& cv) } - if (sm_i+1