History

Fixed issue with far distance of cascades being underestimated, especially first cascade

Olivier Prat committed 8 years ago

Commit c0ca7a11 parent 0b6dcb25 files · +168 −39Browse files

Showing the changes to libraries/render-utils/src/RenderShadowTask.cpp (1 of 5 files). Show all

Unified · Split

libraries/render-utils/src/RenderShadowTask.cpp+3−19
@@ -89,24 +89,7 @@ static void adjustNearFar(const AABox& inShapeBounds, ViewFrustum& shadowFrustum · 88 unmodified lines
8989 for (i = 0; i < 8; i++) {
9090 sceneBoundVertices[i] = shadowViewInverse.transform(inShapeBounds.getVertex(static_cast<BoxVertex>(i)));
9191 }
92− // This indirection array is just a protection in case the ViewFrustum::PlaneIndex enum
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− }
92+ shadowFrustum.getUniformlyTransformedSidePlanes(shadowViewInverse, shadowClipPlanes);
11093
11194 float near = std::numeric_limits<float>::max();
11295 float far = 0.0f;
@@ -278,7 +261,8 @@ void RenderShadowSetup::run(const render::RenderContextPointer& renderContext, O · 165 unmodified lines
278261 minCascadeDistance = std::max(minCascadeDistance, nearClip);
279262 }
280263 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);
282266
283267 // Set the keylight render args
284268 args->pushViewFrustum(*(globalShadow->getCascade(_cascadeIndex).getFrustum()));

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t