Guidelines for creating game with dynamic lights only and good performance

Is there any tips or rules for that?

Limit the number of shadow casting dynamic lights. You can have heaps of non shadow casting dynamic lights with good performance.

Use IES profiles to get interesting looks on smaller lights that can’t cast shadows. Limit the number and influence radius of dynamic shadow-casting lights. Point lights cost ~2x more than spot lights wrt shadows. The cost of shadows is basically: NumberOfLights * NumberOfMeshesAffected * NumberOfTrianglesInThoseMeshes. That’s the GPU cost. On the CPU side, it’s NumberOfLights * NumberOfMeshesAffected * NumberOfSeparateObjects.

Could you confirm what exactly you meant when you wrote “wrt” ? Point lights cost about 2x more than spotlights xxx shadows?

Also do you speak about pointlights with or without shadows?

Hi Bigzer,

WRT = with regards to

was referring to lights casting shadows being ~2x more costly.

I would also recommend the following (hint at Epic^^…would be nice to get this supported natively via code by the Engine for movable lights):

-Make all your lights as BPs
-Add sphere components to them with a certain radius that you think will work good
-Add a large sphere component on the player pawn
-Trigger shadows on/off on impact of those trigger spheres
-limit the max allowed lights amount with shadows on to 4

With this setup, you can have shadows turned on on EVERY light that you place, however, shadows get only turned on when the player is in range (so the spheres overlap) and also not more than 4 lights can cast shadows at the same time.

Frostbite for example has this built in natively for all light types. It guarantees good performance, however you need to place lights intelligent to not get a lot of popping. But thats actually (as far as I know) how all the Engines that fully go realtime do it.

Also, the trigger on impact does not tick, so it keeps your blueprints as cheap as possible. However, native code supoort for no more than 4 lights visible at a time can cast shadows would be the best solution if you ask me :wink:

Whats also quite annoying is the fact that (and this is why you have to turn the shadows off) even if you are not close to the light that casts shadows, the shadow map is still cached and takes up memory. If you have 20 point lights that have cast shadows on, but you cant see them because something is in the way, you still have 20x 2048 rez shadow maps loaded which is responsible for quite a huge performance drop.

It would also be nice to stream them in and out and cull them nicely^^

Cheers! :slight_smile:

1 Like

Automatic enabling / disabling of shadows with fading is already happening, it’s just not exposed per-light and the default settings are very conservative.

r.Shadow.FadeResolution - controls how big the light has to be on the screen before it starts to fade out.
r.Shadow.MinResolution - controls how big the light has to be on the screen before it finishes fading out, at which point it no longer has cost.

You can setup these console overrides for your game to whatever you want. We really should expose it per light.

Dynamic shadows will render if they can possibly contribute to any pixels on your screen, determined via frustum and occlusion culling of the shadow’s bounds. The bounds are a bit larger than the actual visible shadow so it’s approximate.

Dynamic shadows don’t take up any memory, we re-use the same scratchpad for all of them. This will probably not be the case in the future as different rendering methods require them to all be resident at once.

The big optimization that’s missing for movable light shadows is to cache them in memory when both the light and objects are not moving. Individual moving objects can be composited in each frame.

Sorry for updating this thread, but I wanted to ask, if this feature is planning or is there any ideas on how can we make this on our own…

Right now I’m working on my scene with dynamic light (Directional + Sky + Many Point Lights w/o Shadows) and already saved like 20 fps (from 15 to 30 - 50). I’ve used some of mine techniques, but it’s not enough :slight_smile:

This feature cloud give us more boost in performance, and thats why I want to know, if this feature is going to be inside UE4.

I’m also interested in this.

  • There are new Capsule Shadows coming with 4.11 and I’ve heard that they are cheaper than regular shadows. So is it worth to use them on all characters? How much it will boost the performance?