Fit shadowmap to viewFrustum better

This commit is contained in:
Zach Pomerantz 2016-01-15 13:30:29 -08:00
parent 2b27e48bf9
commit b2c9cf7452
2 changed files with 2 additions and 3 deletions

View file

@ -21,7 +21,7 @@ LightStage::Shadow::Shadow(model::LightPointer light) : _light{ light}, _frustum
}
void LightStage::Shadow::setKeylightFrustum(ViewFrustum* viewFrustum, float nearDepth, float farDepth) {
assert(nearDepth >= 0 && farDepth > 0);
assert(nearDepth < farDepth);
// Orient the keylight frustum
const auto& direction = glm::normalize(_light->getDirection());

View file

@ -115,8 +115,7 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const Render
auto nearClip = viewFrustum->getNearClip();
const int SHADOW_NEAR_DEPTH = -1;
const int SHADOW_FAR_DEPTH = 20;
globalLight->shadow.setKeylightFrustum(viewFrustum,
glm::max(0.0f, nearClip - SHADOW_NEAR_DEPTH), nearClip + SHADOW_FAR_DEPTH);
globalLight->shadow.setKeylightFrustum(viewFrustum, nearClip + SHADOW_NEAR_DEPTH, nearClip + SHADOW_FAR_DEPTH);
// Set the keylight frustum
args->_viewFrustum = globalLight->shadow.getFrustum().get();