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

Document how to configure cascaded shadow maps in different situations #7362

Closed
superdump opened this issue Jan 25, 2023 · 6 comments
Closed
Labels
A-Rendering Drawing game state to the screen C-Docs An addition or correction to our documentation
Milestone

Comments

@superdump
Copy link
Contributor

In the cascaded shadow maps #7064 PR, there were some situations raised that require or would benefit from different cascade configuration to the default which focuses on a perspective camera at head height.

One example was a top-down or isometric type view where a lot of the scene objects are within a small depth range and distributed across the screen with no objects close to the camera. In this case probably fewer or even just one cascade with a higher shadow map resolution could be a better choice.

I think it would be good to try out such situations, tweak the settings, maybe adjust the projection’s near plane as @robtfm suggested in the PR discussion as that impacts the view frustum and if I remember correctly also the cascade projection bounds.

@superdump superdump added C-Docs An addition or correction to our documentation A-Rendering Drawing game state to the screen labels Jan 25, 2023
@superdump superdump added this to the 0.10 milestone Jan 25, 2023
@rparrett
Copy link
Contributor

rparrett commented Jan 25, 2023

Here's a little playground I was using: https://gist.github.com/rparrett/0b8a2de7443d41941ad6463e2a42c331

image

I'm not sure if the cascades are following the near plane. edit: they definitely don't

@danchia
Copy link
Contributor

danchia commented Jan 30, 2023

@rparrett you're right - it currently doesn't follow the near plane, but that shouldn't be too large a change. Just need to fix this

line most likely.

@superdump if it feels more natural, I think it would make sense to allow users to configure the near plane direct in CascadesShadowConfig

@rparrett
Copy link
Contributor

Just need to fix this

I attempted that (I think the other bounds need the near plane added as well), but I think there must be something more to it, because the shadows were not even wiggling when adjusting the near plane in the playground above.

At the time I believe this might be due to the "raw bounds" being used here:

.zip(&light.cascade_shadow_config.bounds)

But I was in a bit over my head.

Additionally, there's a question over what shadow_maximum_distance should mean. If it's meant to be "distance from the start of the first cascade" then I think calculate_cascade_bounds needs to be aware of the near plane. Either way, the docs could use a bit of clarification.

@superdump
Copy link
Contributor Author

shadow_maximum_distance is view z distance from the camera position

@superdump
Copy link
Contributor Author

@danchia that sounds reasonable and you’re probably right that that line you referenced plays a significant role in the calculation of the cascade projections.

@superdump
Copy link
Contributor Author

Though perhaps if adjusting that near plane, we’d need to adjust the way the cascades are calculated in general. The first cascade far bound needs to be > the near plane, and then subsequent cascades need to have far bounds coming after that that scale in a sensible way across the range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Docs An addition or correction to our documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants