Raytracing Shadow Distance on Foliage Actors

Hey folks,

I’m running into an issue that seems like it should have a pretty basic solution, but I can’t figure it out. In 4.24, raytracing shadows from foliage actors appear to be based on distance from camera with no apparent way to adjust that distance.

In this image, the line of trees on the right are static meshes that are all shadowing correctly. On the left are foliage actors (using the same static mesh asset) that only cast shadows up to a certain distance from the camera

I’ve looked everywhere in the light, post process, and foliage settings with no luck. Is this a bug?

Thanks to anyone who can provide insight

It looks like the ones that aren’t casting shadows might be at a lower LOD, it might be switching to a billboard.

It’s a good guess but no, they’re all at LOD 0.

Just to clarify (so there’s no confusion about geometry or LODs used) here it is with unreal’s default sphere mesh. Again, foliage on the left, static meshes on the right

Just to bump this - experiencing the same issue. It appears even worse when you have quite dense foliage

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).

Try this console command (use at your own risk :p)

r.RayTracing.InstancedStaticMeshes.Culling 0

Hey, thanks for the reply, but I’m still having issues. That relates to culling of geometry, right? The issue here is behaviour of shadows.

I tried it, and as it implies, it just overrides all geometry cullling - the lack of shadows at a certain distance remain.

Raytracing culling means it doesn’t raytrace that particular foliage painter cluster anymore beyond a certain distance, hence no shadows xd.
Next thing I can think of is to try if your cluster sizes are too small. Raytracing culls very small instanced objects in the foliage painter at quite short distances per default. There’s a console cvar for that too but currently not behind my work-pc so just check the r.RayTracing.InstancedStaticMeshes cvars, it’s one of those.

I was having issues with shadows on my foliage as well and this resolves the issue. It looks like there are some other cull commands to play with so I may try to mess with them to see if there is a middle ground.

r.RayTracing.InstancedStaticMeshes.Culling 1

r.RayTracing.InstancedStaticMeshes.Culling 0

Here are some of the results of playing with the r.RayTracing.InstancedStaticMeshes.LowScaleRadiusThreshold settings.

just curious - or worried rather.
I hope you have about 15 editor things like meshes open and with real-time turned on given the avarage FPS of 30 rate.
IF you don’t, you should probably just disable the shadow on the grass alltogether and just fake it with an albedo offset - make the base darker then the tips.
You really shouldn’t notice any difference visually since most of the shadows are below a pixel in size anyway…

; Whether to include Instanced Static Meshes in BVH r.RayTracing.InstancedStaticMeshes [0|1] ; Whether to enable culling of instance data r.RayTracing.InstancedStaticMeshes.Culling [0|1] ; Scale factor on how large clusters are ; Number represents a scale against the size of instances ; 5.0 means that clusters are 5x the size of the largest ; instance object r.RayTracing.InstancedStaticMeshes.CullClusterMaxRadiusMultiplier ; Distance at which to cull a cluster r.RayTracing.InstancedStaticMeshes.CullClusterRadius ; Threshold for when an object is considered small r.RayTracing.InstancedStaticMeshes.LowScaleRadiusThreshold ; Distance at which to cull small objects r.RayTracing.InstancedStaticMeshes.LowScaleCullRadius Use this Cmd bro!

Haha yeah, I had way more in the scene for testing purposes. That sounds like an interesting way to fake the shadows though, thanks for the tip.

Is Skylight Raytraced Shadows supported on foliage spawned via a landscape material? I cannot seem to get spawned grass to cast RT shadows. Grass painted using the foliage painter does cast RT shadows. The spawned meshes are defined as InstancedGrass rather than InstancedStaticMeshes, so the console vars in this thread won’t work. Does anyone know a workaround (other than hand painting all the foliage)?

so, how do you do that? **fake it with an albedo offset **?
is there any tutorial you can point me to?


No real need for a whole tutorial on it.
Usually you have some white to dark tint already applied to the the mesh, be it your vertex paint or an albedo.
Take the texture or paint, and multiply by the albedo texture so that the tips are whiter then the bottom.
Alernatively make a texture or pack one in a channel specifically for this.
The purpose is to have the bottoms of the blades significantly darker then the rest of the blade. This simulates the effect that a shadow would have without paying the cost for it.

Additionally, you can set 2 or 3 of the same mesh to different distsnces so that the near one has real shadows and a material without the darker effect, but the further one does not.