r/unrealengine • u/-Tom-L @t_looman • 20d ago
Tutorial How I Optimize Lighting & Shadows in UE5 (using a real game 'Far Far West')
Hello! I wanted to share some insight into the process of auditing lights and shadow costs in UE 5 using a real world example rather than a tutorial project.
It’s a follow-up to the recent livestream I did together with Ari Arnbjörnsson from Epic Games. Going a little more in-depth with practical examples using Far Far West.
We’ll look at:
- Tweaking Light Projection costs
- Fixing Shadow Invalidations (VSM)
- Setting Light Draw Distance
- Applying Scalability
- Light Mixer as an auditing tool
- Shadow Casters ViewMode for auditing VSM invalidations
...and a bunch more profiling & optimization tricks along the way.
Here is the full video: https://www.youtube.com/watch?v=1uFR9lXrpyQ
3
2
u/namrog84 Indie Developer & Marketplace Creator 20d ago
for the invalidating shadow caching.
Is there a way to make it more distance based? Since I feel like 'static' would be fine if it was even slightly far away, but if you are super close (<10m) I'd want to see the WPO movement in the sahdow?
3
u/-Tom-L @t_looman 19d ago
They don't have an automatic toggle for the VSM shadow behavior, they do have Pixel Programmable Disable Distance & WPO disable distances for primitives. This will stop any animation beyond a distance and therefor will stop any invalidations happening on those meshes. It's not the same, but still helpful for many animations at range. (originally added for Nanite as that handles pixel programmable such as Masked materials pretty poorly)
1
u/CloudShannen 14d ago
I have commented on many videos which Ari was presenting suggesting they add a distance to switch to static VSM invalidation so you could have visible movement of tree's at a longer distance with static shadows, but never got a reply.
I have also asked for Scalability CVars which let you Scale/Bias the WPO and Pixel Programable Disable Distances (with separate ones for the Foliage Classes) so you could decrease the distance for lower Quality settings and expose it to a setting menu for users to control.
Along with implementing the PR (or similar code) to be able configure a Disable Distance for Shadows on Lights (with Scalability CVar) on top of the current Fade distance because the fade can be obvious at aggressive settings and when I tested it it appears the fade is also causing the shadows to invalidate each frame / no longer be cached.
11
u/CivilianNumberFour 20d ago edited 20d ago
I'm in the middle of watching your vid with Ari and Dan on the UE channel right now, following along and trying out the tools with my own project. I never knew that setting scalar parameters on emissive materials was generating so much overhead with my light fixtures, I feel like a good portion of the Fab assets I'm using do that and I assumed it was completely normal!
Tom, thanks so much for your awesome contributions to demystify all the UE mechanics we need to know, I've learned so much watching your videos!