How are you guys optimizing many dynamic light sources (e.g. in a large open world)? I did some testing and the shadows are responsible for killing the performance. So what would be good practice/your ways of tackling that performance issue? Working with Virtual Shadow Maps and Lumen.
(in Project Settings)
-Shadow Map Method: Shadow Maps
-Global Illumination Method: None
Try these while working on your project, when you do r.ForceLOD 0 it will also give you a lot of performance (if you have many static meshes like trees), disabling shadows completely when working in regions of your map with a lot of trees or other foliage can also help ouf a lot
That in part depends on what shadowing method you’re using. Traditional shadowmaps, VSMs, DF shadows, screen traces, some combination thereof?
If you’re using VSMs, one of your main priorities needs to be making sure every single object that’s being shadowed is nanite. Non-nanite geo is very expensive for the pipeline and will utterly kill perf.
in raytracing you have r.manylights. it’s beta tho. in a “regular” world you gotta make compromises. disable shadows where you don’t need them. use ambient lighting to avoid having too many lights to get the scene bright enough. avoid light overlap as much as possible. attenuation radius down to necessary ranges. avoid every unnecessary piece of computation.
Thanks! Setting the attenuation radius to prevent overlapping is quite tricky for me, since I cant predict where the player is building a lightsource (e.g. a torch). Are there any good practices what to do in that case?
Also what does ambient light refer to in that context? Like a cubemap that does slightly light everything?
Thank you! Yes, I am working with VSM. I updated my post! I Already checked that, and everything is nanite. But still I am wondering how I can bring down the performance cost even further.
If it’s player built then you can either prevent them from placing light sources too close together, or allow them to negatively impact their own performance by not restricting this in any way.
Perhaps if you display the radius in game when placing a light players would naturally avoid overlapping them to an extent.
hmm. this is pretty deep engine optimization. if the world is build by the player you may want to have a hybrid render that can bake dense shadows into static shadow "light"maps and you may want to combine dense lighting into irradiance volumes. doing this on the fly is a pretty gnarly technique. will need a fair amount of computation on the user’s device.
Something we’ve been playing with is reusing lights by moving the furthest lights to proximity - also, we’re using singleton interiors to buildings which get moved into the closest house - that allows for a lot of lights. Also swapping lights for emmissive based materials in the distance.
I mainly set the draw distance on the light - to what distance should it be drawn.
light radius - the smaller the better. In advanced settings, there is a light falloff exponent, in case you want the light to shine near the border of the radius.
If you can shine a light without a shadow - it is very cheap.
I don’t use pointlights, only in rare cases - they are much more expensive in terms of performance than spotlights. Spotlight with large radius can be preaty heavy. same for rect lights.
I don’t rely on Lumen, its indirect lightning and emissive materials - they are turned off on medium settings, but they increase your FPS performance a lot (in my case, even double). that’s why I have set the scene so that it looks very similar both on Epic and on medium (it is necessary to match DFAO for medium details (skylight settings) and skylight leaking (postprocess volume settings for Lumen).
But for medium settings, i needed turn of DFAO specular occlusion on 5.3.2, because it doesnt work properly (interiors were grey and shiny as hell)
I don’t use distance field shadows anymore - they are still turned off on medium.
I pay attention to the light in the interiors, so that the light complexity does not increase - a pair of lights, half on one side of the wall, the other on the other can cross radius and can cause more fps drops.
Less is better - sometimes is better less lights for better atmosphere (like 70 percent on screen are shadows).
For classic shadows, there is max shadows distance and distance field shadows distance options
Thanks for the many answers - that will give me a good idea what I have to keep in mind! Do you guys know, if you can fade between light sources, where one has shadow enabled and the other not (still working with VSM)? The aim would be to smoothly fade between shadow/non shadow in relation how far the player is away from a light.
no. shadows can only switch on or off. there’s no smooth transition. depending on the light situation it would look rather weird to go frrom shadowed to fully lit anyway. the other way would be more appropriate… to fade the light intensity to zero or ambient or fog value and switch it off. a more natural fade.
Alright, thank you!