Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSM Improvement: Calculate the best fit frustum for shadow map #29831

Open
ligaofeng0901 opened this issue Nov 7, 2024 · 0 comments
Open

CSM Improvement: Calculate the best fit frustum for shadow map #29831

ligaofeng0901 opened this issue Nov 7, 2024 · 0 comments

Comments

@ligaofeng0901
Copy link
Contributor

Description

So far, we use OffsetCSMShadowNode to get CSM effect in a scene. We can pass some parameters to this node when constructing. In the file https://github.com/mrdoob/three.js/blob/dev/examples/jsm/csm/CSMShadowNode.js#L369 OffsetCSMShadowNode update transfrom of each internal light in each frame. but the frustum value(.left, .top, far...) of shadow map camera doesn't update, which clones from the main light at the begining.

Solution

Because the frustum of each shadow camera may be bigger or smaller than the view frustum, It may cause a waste of shadow map or lost some shadow area. I think we should calculate the best fit frustum for shadow map automatically in three.js.

I've tested some way to get it. some code like this: ligaofeng0901@2a00ba9
It can get a better tight box for shadow camera, get better quality of shadow.
490bc465ca3c3e5af64ab1af94ab1997

Alternatives

But there are more sitiuation should be considered, the box should be a little bigger than the tight one, but the margin of each box should not be a constant. Also, if .fade is true, some blank area will appear.

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants