-
-
Notifications
You must be signed in to change notification settings - Fork 110
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
Cascaded shadow map support #461
Comments
Sorry for the late reply 😬 Hope you're still up for the task, it sounds like a really nice addition! It's definitely aligned with the goals of three-d. I think being able to swap out the shadow algorithm of each light is a bit overkill. If someone really wants to implement their own shadow algorithm and don't want to contribute to I think the best approach to add cascaded shadow map support in three-d is changing the existing |
The way I did Cascading Shadow Maps (using Variance Shadow Maps) was to:
In the end we needed to do this anyway though, as we need to emulate
However currently when writing custom shaders that end up replace certain parts of their inner fragment / vertex shader, running into issues with the panic behaviour of One additional complication I've run into is that Variance Shadow Mapping and other techniques greatly benefit from mip maps, however there is currently no way to limit the number of mip levels when creating textures and updating all 10+ levels for multiple cascades per frame is rather slow (hence why my implementation is only using two levels). TL;DR; a list of small things that would be nice to have:
|
Thanks for the effort @BonsaiDen! I'm not sure what makes this so much different from a normal shadow map, it's basically just more maps 🤔 I think it makes more sense to support it in each of the existing light types instead of implementing a new one. But of course, that requires changing |
Most of the troubles come from edge cases when rendering geometry into the cascades (e.g. the clamping I mentioned), there's an endless amount of tradeoffs and config options to make it look good for different scenes. I guess splitting the Light and Shadow logic would a be a good first step, i.e. keep the Light trait, but move the shadow rendering out in it's own Each btw: The recent introduction of the Viewer trait (removes the shader rewrite hack for the projection matrix above since I can now supply an impl with the per-cascade projection) and the removal of the FragmentAttributes definitely made things easier to tweak / customize! 👍 |
I'm adding cascaded shadow maps to my own project, and I'd be open to contribute an implementation back to three-d, but I'm not spotting a great way to plug new shadow map backends into the existing lighting system.
Since cascaded shadow maps require changes to both shadow map generation and sampling, we'd need a way to provide replacements for both
Light.shader_source()
andLight.generate_shadow_map()
. The most strait forward is to add aShadowMapper
trait (name needs workshopping), but that would requireLight
to becomeLight<S> where S: ShadowMapper
, which has knock-on effects up and down the API. Or maybe alternatelyLight
could contain ashadow_mapper: Box<dyn ShadowMapper>
. Or we could make the caller explicitly pass anOption<&ShadowMapper>
into the two functions that require it...Do you have a preferred approach here? Is adding fancier shadow algorithms a good fit with the goals of three-d?
The text was updated successfully, but these errors were encountered: