Showing the changes to libraries/render-utils/src/RenderShadowTask.cpp (1 of 5 files). Show all
Unified · Split
| @@ -89,24 +89,7 @@ static void adjustNearFar(const AABox& inShapeBounds, ViewFrustum& shadowFrustum · 88 unmodified lines | |||
| 89 | for (i = 0; i < 8; i++) { | 89 | for (i = 0; i < 8; i++) { |
| 90 | sceneBoundVertices[i] = shadowViewInverse.transform(inShapeBounds.getVertex(static_cast<BoxVertex>(i))); | 90 | sceneBoundVertices[i] = shadowViewInverse.transform(inShapeBounds.getVertex(static_cast<BoxVertex>(i))); |
| 91 | } | 91 | } |
| 92 | // This indirection array is just a protection in case the ViewFrustum::PlaneIndex enum | 92 | shadowFrustum.getUniformlyTransformedSidePlanes(shadowViewInverse, shadowClipPlanes); |
| 93 | // changes order especially as we don't need to test the NEAR and FAR planes. | ||
| 94 | static const ViewFrustum::PlaneIndex planeIndices[4] = { | ||
| 95 | ViewFrustum::TOP_PLANE, | ||
| 96 | ViewFrustum::BOTTOM_PLANE, | ||
| 97 | ViewFrustum::LEFT_PLANE, | ||
| 98 | ViewFrustum::RIGHT_PLANE | ||
| 99 | }; | ||
| 100 | // Same goes for the shadow frustum planes. | ||
| 101 | for (i = 0; i < 4; i++) { | ||
| 102 | const auto& worldPlane = shadowFrustum.getPlanes()[planeIndices[i]]; | ||
| 103 | // We assume the transform doesn't have a non uniform scale component to apply the | ||
| 104 | // transform to the normal without using the correct transpose of inverse, which should be the | ||
| 105 | // case for a view matrix. | ||
| 106 | auto planeNormal = shadowViewInverse.transformDirection(worldPlane.getNormal()); | ||
| 107 | auto planePoint = shadowViewInverse.transform(worldPlane.getPoint()); | ||
| 108 | shadowClipPlanes[i].setNormalAndPoint(planeNormal, planePoint); | ||
| 109 | } | ||
| 110 | 93 | ||
| 111 | float near = std::numeric_limits<float>::max(); | 94 | float near = std::numeric_limits<float>::max(); |
| 112 | float far = 0.0f; | 95 | float far = 0.0f; |
| @@ -278,7 +261,8 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, O · 165 unmodified lines | |||
| 278 | minCascadeDistance = std::max(minCascadeDistance, nearClip); | 261 | minCascadeDistance = std::max(minCascadeDistance, nearClip); |
| 279 | } | 262 | } |
| 280 | maxCascadeDistance = std::min(maxCascadeDistance, farClip); | 263 | maxCascadeDistance = std::min(maxCascadeDistance, farClip); |
| 281 | globalShadow->setKeylightFrustum(_cascadeIndex, args->getViewFrustum(), minCascadeDistance, maxCascadeDistance, shadowOverlapDistance, SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR); | 264 | globalShadow->setKeylightFrustum(_cascadeIndex, args->getViewFrustum(), minCascadeDistance, maxCascadeDistance, |
| 265 | shadowOverlapDistance, HIGH_CASCADE_MAX_DISTANCE, SHADOW_FRUSTUM_NEAR, SHADOW_FRUSTUM_FAR); | ||
| 282 | 266 | ||
| 283 | // Set the keylight render args | 267 | // Set the keylight render args |
| 284 | args->pushViewFrustum(*(globalShadow->getCascade(_cascadeIndex).getFrustum())); | 268 | args->pushViewFrustum(*(globalShadow->getCascade(_cascadeIndex).getFrustum())); |