Raytracing Shadow Distance on Foliage Actors

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

2 Likes

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.

2 Likes

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

1 Like

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

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

thanks

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.

FYI - this command has changed - if you search for the old one above you won’t find it. The new one is:

r.RayTracing.Geometry.InstancedStaticMeshes.Culling 0

8 Likes

THANK YOU!!!

Is it working also for UE5? I tried this commands to get the shadows for the foliage working in the distance, but it doesnt work for me… Maybe I m missing something, anyone can guide me please, thanks

2 Likes

Try painting the meshes as static, not moveable and see if that helps. You can find that setting in foliage mode

try to check postprocess - lumen global illumination - rize value of lumen scene view distance and max trace distance

For me, it doesn’t help if I rise those values from 1000000.0 to 2000000.0
UE 5.2

If you have this problem with raytraced shadows and grass foliage, try out r.RayTracing.Culling.PerInstance 0 to disable culling shadows for foliage instances.

1 Like

You’re a saint Tytanit! Thank you. This works for me