Download

Help me understand how shadows work for the foliage tool.

Hi, I’m trying to learn to create stuff in unreal.

I have encountered the following problem: while having dynamic lighting, spawning grass with the foliage tool causes the shadows to abruptly disappear. I haven’t tried with static lighting, because I NEED dynamic lighting for a day/night cycle.

I’ve messed around with the settings on the instanced static mesh foliage, to no avail too. My educated guess is that the foliage tool is bunching together the shadow maps, and something goes wrong since I have 500k grass blades and 14 bushes (I tried to only have 1 bush, it doesn’t seem to have anything to do with there being too many things)

It’s (hopefully) a checkbox or slider that I’m too blind to see, but at this point I’ve spent ~10 hours trying to fix this, over the course of 2 days. Pls help :^)

With blue I have marked the stuff spawned with the foliage tool. With red, the static meshes I have spawned manually. What I know is that messing with the cascaded shadow maps settings on my directional light can influence the shadows on the foliage, but I can’t get it right no matter what I try. I’ve used the default bush, rock and cube. For the grass I made my own little model which is basically a small pyramid.

Did you set them to moveable?

Also, maybe take a look at this:

So foliage tool objects shadow for me correctly in an empty scene with just a movable point light.

Maybe create an empty working test scene, and add from your scene until it breaks…

There is a range to the distance of the instanced shadows from the camera.
Computations seem to be made between angle of landscape, angle of sun, angle of mesh, and shadow intensity :

Difference between near shadows and distance shadow:


Far distance.

With that in mind (and my foliage is **not **set to movable, but it does have static shadows disabled)

You can now work on your directional light.
In it’s details panel type “dist”

Under cascaded shadow maps you have some options.

Distribution exponent - changes the distance at which the switch between the 2 different intensities occur.
Use in combination with Distance Fadeout Friction.

Play with those 2 values to find the setting that makes you happy - ON your final scene.

Reference settings on the mesh brush:
ref.settings.png
As you can see, I don’t even have Distance Field enabled.

Obviously, this is for a Dynamic light setup.

Not done I guess.
Other settings that can help:
Shadow Cascade bias Distribution

Reducing Shadow Amount to get a better matching of the Near shadow to the far shadow.

You can refer to this for some more info on what does what

Additionally you may want to Force no precomputed lighting in lightmass.

Steve,

We are having the exact same problem with ray-traced shadows in 4.24:

So far, it’s incredibly frustrating, but we have had no solutions so far.

We are using a generic sunsky (movable point light) in 4.24.

Why would the shadows cut out in the middle distance on Foliage objects with ray-tracing enabled?

Thoughts? Anyone? (Help!)

-Donald

2 Likes

Ray tracing is still “experimental” or “beta” essentially and literally has nothing to do with the foliage shadow or instanced mesh shadow issue.

if you can, you should probably combine the shadow types to solve your issue.
Ray traced up close, dynamic shadows at a range.
you may be able to do this via LOD settings on the object perhaps.

This is likely a need for performance too, ray tracing every shadow on the map is just as expensive if not more expensive then dynamic shadows.
At a distance, the accuracy of a ray traced shadow becomes somewhat irrelevant (depending on the size on screen of the shadow just like LODs).
You are limited entirely by the single size of a pixel when rendering it, so the shadow further out will probably have blurred edges anyway compared to one up close at least.

I would imagine that mixing the shadow type between traditional and ray-traced if possibe would give you very little visual difference and a high performance boost to the draw call/time.

That said. have you given the shadow bias and the other options I mentioned above a try already?
do they have any effect at all?

Yeah I tried it, it looks pretty bad. The only option I see is spawning each plant by hand instead of using the foliage tool (ahaha, no). The popping is just, bad man.

Told my senior, he said he’ll send a report to epic.

1 Like

MostHost,

I’m confused by your statement that, “Ray tracing … literally has nothing to do with the foliage shadow or instanced mesh shadow issue.”

Our issue happens only when ray-tracing is on and only when rendering foliage and our issue looks exactly like Steve’s example at the top of the thread where there is an abrupt cut-off between objects that have shadows and objects that do not (not like CSM shadow issues in your captures).

Steve: can you clarify, are you using ray-traced or mapped shadows?

Performance is a non-issue for us: we value accuracy over interactivity. It would be cool if we could mix ray-traced and mapped shadows (with post volumes?) but I haven’t seen a way to control the type of shadow at the LOD, asset or actor levels.

We just need to know if there is a bug with ray-traced foliage or not.

Thanks for your help!

-Donald

I’m having the exact same problem - and came here to post about it! I’ve noticed it only occurs at a set point from the camera (around 10000 units), and it makes no difference when I’m using and HDRI or a more traditional directional light (even with cast ray traced shadows off and reverting to CSMs).

Has been driving me crazy, hope there is a workaround I’m not aware of, or a fix incoming!

Sorry, I haven’t checked in a while, we just kinda moved on with how it was, and hid it with clever camera work.

It happens with ray tracing.

Sorry to summon this from the dead but anyone had any insight into this? I’m struggling with the same problem. I have scattered grass and other greenery - the large and medium sized cast shadows as expected but the smaller ones don’t cast any shadows. Also - related to this problem. As I move camera even just a tad further away the smaller shadows disappear. I have raytracing on, all my grasses are ‘movable’ and I’ve forced LOD 0 via command line. Any ideas how to solve this?

The only successful build in which I had less issues getting something to render was with using the latest (which is not the latest anymore) nvidia ray tracing branch.

However, at a distance. Distance Field based shadowing is the same (it looks the same) and performs much better.

So unless you need to set up for a 4k video render or a still that absolutely has to be ray traced, you may want to consider mix/matching your shadowing options…

Thanks for replying,
As a novice UE artist could you explain a little bit more how to mix the shadow options for the smaller grasses to shadow correctly?

first, if you are using the Grass to render grass. Unless this is for something specific where you need shadows.
The very first thing to do is turn off shadow casting on all grass meshes.
For grass, the shadow needs (still, maybe next year with the new GI this won’t be a performance “must” anymore) to be faked.
Normally, you do this by darkening the bottom of the grass mesh using the Vertex color that you already have set up to enable wind - all within the material.
At a distance, You really can’t tell if a grass mesh is casting shadows or not - so long as visually the lower portion of the plant is darker than the top.

Second. the shadow thing… let’s just go with this. the guy explains it a lot better than I can in a forum post.

It also covers how to set things up. If you need more help just ask for the specific use case :wink:

Thanks for the info. I’ll look through the video and post here if there’s some additional questions.
For the MS grass that I’ve scattered using foliage tool I do need proper shadows - the environment is for a cinematic and we’ll be seeing the ground very close. So performance is not an issue here I just really need it to behave like everything else in the scene.

1 Like

I watched the video and while it clearly explains the basics it really doesn’t provide anything that would help me to solve the problem of missing shadows on my foliage. I wonder if this is just a bug and there’s no solution at the moment.

I have distant shadows working via distance fields.
Not sure if that applies to you or not, but it is most definitely a way around the problem (granted, with its own limitations).

Thanks for the tip - I’ll look into this. I’ll post my results with some screen grabs after I’ve had a little time to play around with this.