Static lightning for performance and dynamic shadows for looks?

If you set both skylight and directional to stationary and build light. Then on the directional light increase the parameter ’ dynamic shadow stationary light’ ( something like that ).

This means you get static shadows beyond this distance, and dynamic shadows under it.

Best of both worlds.

Is there a way to pre-calculate dynamic shadows into static shadows to improve performance (especially for foliage)? I have quite many foliage which work fine mostly, but when those are completely occluded (player inside a house) the performance suffers a lot. I checked with a profiler and found that rendering cascade shadows for the sun renders a lot of triangles.

I tested with shadow maps and removed dynamic shadows from the grass and other small foliage, but it looks bad:

I also get huge amount of shadow map popping (objects go completely black when moving little):

Dynamic shadows look just great when enabled on foliage and outside it also works great:

So, is there any way to get dynamic shadow look with static shadows? There seems to be quite significant performance impact when enabling shadow maps compared to fully dynamic rendering. Best would be to render landscape and foliage with static shadows (if the shadow quality is good enough) and render other parts of level fully dynamically (as i have other level assets moving). I have no idea whether it’s even doable, even in theory…

Thank you for a good idea. I did try it out however it seems that dynamic objects kill the performance on shadow casting when using stationary light source. With fully dynamic rendering, it creates cascade shadows runtime and the performance hit was as a whole “reasonable”. Dynamic lighting I get about 70fps when looking at structure constructed fully on dynamic parts. With static and dynamic shadows i get only 17fps which is huge difference. Based on profiling its creating separate shadow projection for each and every actor. I don’t know is there some setting that would allow baking some shadow maps for dynamic object. Tried with directional light’s “Force Cached Shadows For Movable objects” but it doesn’t seem to help.

Have too keep digging for other options…

I only noticed frame rates jump by about 30fps.

If it’s all dynamic, there’s a lot of work to do. If it’s all static apart from the shadows within a small range ( like 1200 units ), it has to be better.

Sorry, can’t find it now. There’s a very good Epic doc page about it.

The system only has to light the area around the player. The trade off is the amount of memory taken up by the lightmaps for the stationary parts.

I was thinking that if I could somehow split the structure into sections based on visibility of a certain box and based on it, I could hide everything in that area (like the occlusion does in rendering). This would allow me to remove objects based on the fact that they could not be seen directly or indirectly on view and therefore improve performance.

In dynamic rendering I tried different options. Changing the rendering size didn’t affect basically at all. Hiding foliage did help somewhat (75->105fps) as there are a lot of it to render into shadows and none is show in that particular place I used for tests.

In these tests the sun is coming behind of me and the structure is in front of me (98% occluded by visibility). When I change the sun to come 180 deg into front of me I get 75->100fps, even with foliage. Of course it depends from the direction where the light is coming and where the foliage is located related to it.

Changing shadow number of shadow cascades from 5 to 4 gives just a few fps (and adds artifacts on some locations). Changing dynamic shadow distance for movable light from 20000 into 2000 gives just around 75->85fps. Setting it into 0 give me 75->105fps. Disabling the light altogether gives the same result (105fps). Disabling all other lights except the sun gives 85fps and disabling all lights in the scene (as most are in front of me, but behind walls) is solid 120fps limited by the engine.

And for reference, the scene in the initial post. In dynamic lighting, volumetric shadows and all is solid 110fps.

What you’re talking about initially, have you seen:

?

I didn’t know that component beforehand, however it seems to have a bit too little functionality I need. As I can’t hide based on size or distance alone I was planning something similar to hardware occlusion queries defined in Visibility and Occlusion Culling | Unreal Engine Documentation . I might be able to create this with custom stencil buffer writes, but I would need to read it back and the functionality can’t be done in materials alone.

I was hoping to be able to use i.e. custom stencil values for certain objects in scene and based on visible values enable/disable visibility of group of objects. Have to took into that further…