#Low quality shadows from DirectionalLight

1 messages ยท Page 1 of 1 (latest)

grim seal
#

I'm using default DirectionalLightBundle (with shadows enabled, of course), and i tried using DirectionalLightShadowMap { size: 4096 } but that didn't really help. I tried tinkering with CascadeShadowConfig and some settings do help, but that's mostly random luck. Are there some common sense settings for pretty simple scenes such as mine?

grim seal
#

ok so when i decrease maximum_distance at some point i don't see any shadows at all

#

and another observation: shadows for faraway objects seem fine with default settings (distance 1000)

#

so it's a choice between bad shadows for near objects vs no shadows for far objects ๐Ÿค”

hasty scroll
#

You have to adjust CascadeShadowConfig based on your scene but if you have a large range of distances that require shadows (sounds like that's your case) then you will run into this issue. I think there is a fix for this on main (shadow filtering https://github.com/bevyengine/bevy/pull/8006) but I haven't tried it out yet. It will be included with the 0.12 release

grim seal
#

should i try to tinker with something else other than max_distance?

#

i think i understand the problem conceptually btw: i'm making an rts game, there are large distances between objects, but typically you aren't supposed to view one object with camera being at another object. like, all the view is top-down and potential max distance to camera is relatively small
but in my case, i added a flying camera to be able to look around freely, at any angle. that's not really supposed to be happening in the game, and it results in very large viewing distances

#

it's kinda fun to watch it work after i learned how cascaded shadows work. but ye at some specific distances the aliasing is just really quite bad

#

like these are great

hasty scroll
#

For a flying cam I just use the default settings except for the maximum_distance and it looks quite good already:

    let cascade_shadow_config = CascadeShadowConfigBuilder {
        maximum_distance: 200.0,
        ..default()
    }

Anything outside of the maximum distance I hide with fog.
For top-down you may want to look at minimum_distance and first_cascade_far_bound as well

grim seal
#

go up, seemingly hitting another cascade. worse, but tolerable quality.

#

go up a lot more. same cascade, looks very good from this distance

#

go up a bit further, hit another cascade, and all of a sudden it's a total wreck

#

i included more in the last pic to show that the further away ones (vs original that i showed) are also not looking good

hasty scroll
#

You can increase the overlap_proportion to make the transition more subtle, but I think that's the expected behavior without shadow filtering

#

Basically you just have to wait a few weeks (or use main) or try to hide the issue by limiting the max distance

grim seal
#

i would mostly attribute it to myself not really knowing how cascaded shadows work. i still don't (fully), but at least some things are understandable ๐Ÿ˜„

#

my main learning tool is trying to tinker with something, that's why i like inspector so much. but cascaded shadows are configed through the builder, so it's harder to tinker to figure things out

hasty scroll
#

Ah yeah

#

But I think it's good timing to learn this now, because with shadow filtering it would have been more difficult to see what is going on under the hood

grim seal
#

i assume that with lower max_distance the transition between cascades are also just naturally smoother

#

with the same amount of cascades

hasty scroll
#

indeed

grim seal
#

i'm also kinda surprised that cascaded shadows came to Bevy pretty late

#

i didn't really know about how they work exactly but now i think they're quite crucial ๐Ÿ™‚

hasty scroll
#

Yeah rendering stuff is difficult and it's all being done by people working on it in their spare time

#

But really good progress is being made

grim seal
#

i don't fully understand first_cascade_far_bound though. the default is 5%. what does it mean? like, first cascade goes from 0% to 5%, second from 5% to x%, etc? (can't tell which x because it seems it's non-linear but exponential)

#

*0% to 5% of viewing distance

hasty scroll
#

Afaik it's not a percentage, just distance (unitless). The rest of the cascade bounds get calculated based on your CascadeShadowConfigBuilder settings (which is exponential indeed)

grim seal
#

ahh it seems in the same units as distance

#

i also figured out why shadows looked just particularly aliased. it's because i use camera's fov change for zooming in and out

hasty scroll
#

Ahh good catch

grim seal
#

thanks for the help, i'm now even more excited about 3d ๐Ÿ™‚

hasty scroll
#

Awesome! No problem

icy moat
#

idk if it's been mentioned here yet but PCF in bevy 0.12 will also make the shadows smoother