-
-
Notifications
You must be signed in to change notification settings - Fork 20.9k
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
[3.x] Allow non-power-of-two directional shadow size in 3D #54042
base: 3.x
Are you sure you want to change the base?
Conversation
Does this work well when using many lights in the shadow atlas? AFAIK the reason it was limited to power of 2 was because the shadow atlas is recursively subdivided to provide space for all the shadow maps. I am concerned that odd numbers may lead to odd rendering artifacts when many lights are used. |
8d0c46f
to
1655067
Compare
I've tested it again with a larger scene and can confirm that point light shadows break with NPOT sizes 🙁 I reverted the change for the point light shadow atlas size, but I kept it for the directional shadow size. The behavior in
Testing projects: |
1655067
to
8fcc597
Compare
I've amended this PR to allow setting the directional shadow size to NPOT values in GLES2 as well. Based on my understanding, NPOT textures in GLES2 work as long as they aren't set to repeat and have no mipmaps. So far, it works on my desktop PC, but it needs to be tested on Android and HTML5 at least. 20483072 (new possible value)4096 |
8fcc597
to
dd86d50
Compare
71cb8d3
to
c58391c
Compare
dd86d50
to
5015047
Compare
This allows for more finegrained performance/quality tuning, especially at higher sizes. Any number can be used. 3072 and 6144 are sensible shadow sizes that can be used if the default 4096 is too slow or too low-resolution for a large scene. This also updates the point light shadow atlas size property hint to reflect that it can be changed without restarting the engine. Nonetheless, it's still rounded to the next power of 2 since the atlas relies on dimensions being powers of 2.
5015047
to
132b8a9
Compare
3.x
version of #54041.This allows for more finegrained performance/quality tuning, especially at higher sizes. Any number can be used. For directional light shadows, 3072 and 6144 are sensible shadow sizes that can be used if the default 4096 is too slow or too low-resolution for a large scene.
This change only applies to GLES3, as NPOT texture support is not present on all devices that support GLES2. When using GLES2, shadow sizes are still rounded up to the nearest power of 2. It might be possible to support it regardless, but I'd rather not risk it, especially on mobile platforms.Edit: Temporarily allowed in GLES2 to check if it works on mobile/web platforms.
This also updates the point light shadow atlas size property hint to reflect that it can be changed without restarting the engine.
Preview
Point light
point-shadow-size-npot-3.x.mp4
DirectionalLight
4096 (default)
6144 (new possible value)
8192