mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 21:57:00 +02:00
Fit shadowmap to viewFrustum better
This commit is contained in:
parent
2b27e48bf9
commit
b2c9cf7452
2 changed files with 2 additions and 3 deletions
|
@ -21,7 +21,7 @@ LightStage::Shadow::Shadow(model::LightPointer light) : _light{ light}, _frustum
|
||||||
}
|
}
|
||||||
|
|
||||||
void LightStage::Shadow::setKeylightFrustum(ViewFrustum* viewFrustum, float nearDepth, float farDepth) {
|
void LightStage::Shadow::setKeylightFrustum(ViewFrustum* viewFrustum, float nearDepth, float farDepth) {
|
||||||
assert(nearDepth >= 0 && farDepth > 0);
|
assert(nearDepth < farDepth);
|
||||||
|
|
||||||
// Orient the keylight frustum
|
// Orient the keylight frustum
|
||||||
const auto& direction = glm::normalize(_light->getDirection());
|
const auto& direction = glm::normalize(_light->getDirection());
|
||||||
|
|
|
@ -115,8 +115,7 @@ void RenderShadowTask::run(const SceneContextPointer& sceneContext, const Render
|
||||||
auto nearClip = viewFrustum->getNearClip();
|
auto nearClip = viewFrustum->getNearClip();
|
||||||
const int SHADOW_NEAR_DEPTH = -1;
|
const int SHADOW_NEAR_DEPTH = -1;
|
||||||
const int SHADOW_FAR_DEPTH = 20;
|
const int SHADOW_FAR_DEPTH = 20;
|
||||||
globalLight->shadow.setKeylightFrustum(viewFrustum,
|
globalLight->shadow.setKeylightFrustum(viewFrustum, nearClip + SHADOW_NEAR_DEPTH, nearClip + SHADOW_FAR_DEPTH);
|
||||||
glm::max(0.0f, nearClip - SHADOW_NEAR_DEPTH), nearClip + SHADOW_FAR_DEPTH);
|
|
||||||
|
|
||||||
// Set the keylight frustum
|
// Set the keylight frustum
|
||||||
args->_viewFrustum = globalLight->shadow.getFrustum().get();
|
args->_viewFrustum = globalLight->shadow.getFrustum().get();
|
||||||
|
|
Loading…
Reference in a new issue