-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Allow changing directional shadow size at run-time #54165
Allow changing directional shadow size at run-time #54165
Conversation
Factoring out the directional shadow creation code allows calling it at any time. This works in both GLES3 and GLES2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I think if we do this then we need to expose an enum for size, otherwise the buffer will be reallocated every time the slider updates. On good hardware, that works fine, but on lower end hardware it will make the slider impossible to use.
The code that compares the "old" and "new" shadow size already uses |
This looks very useful! Another option, worth discussing at least (and potentially more for 4.x), is changing the matrices / glViewports and change the shadow map size per frame, without requiring re-allocation. This would allow dynamically scaling performance as you moved around a map. This is similar to the often used technique of scaling the main viewport for rendering (then upscale to final result). I've never used this but it may not be that complex to implement, and would be an interesting experiment. |
71cb8d3
to
c58391c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry didn't go through this properly at the time. Given the comments about the check for power of 2 it sounds like it doesn't cause constant reallocation.
This is also something that can use #53296 when we finalize that to prevent checking the setting unless there have been changes.
Thanks! |
Factoring out the directional shadow creation code allows calling it at any time. This works in both GLES3 and GLES2.
This makes no performance difference when the feature isn't used. In the test scene, I get 540 FPS with and without this PR.
With this change, we can look into exposing support for 16-bit shadow buffers (in a future PR) including run-time changes of the precision setting. This can improve performance without impacting visual quality much, and is already the default in the
master
branch.Edit: Done in #57430.
This fixes #18621, #30087 and #30241 in
3.x
(these were already fixed inmaster
).Preview
GLES3
gles3-runtime-directional-shadow-size-change.mp4
GLES2
gles2-runtime-directional-shadow-size-change.mp4