Bake shadow without light

Hi everyone,

In our games we have a level in which player must enable lights to lit the world and progress. For the moment we are using stationnary lights but the limit for overlapping stationnary lights don’t allow us to lit as we would want (we have huge attenuation radius), and dynamic shadows are too expensive.

So my idea was to have a copy of a light and bake only its shadows (I don’t want the lightmap, just the shadow map). So the player enable a dynamic light with cast shadow disabled and I should have a reasonnable performance cost.
I don’t need to hide shadowmaps at runtime, I can have them showed from start, as the sky light intensity is very low the shadow should not be a problem when not lit.

The problem is I have no idea on how to cast shadows without lighting. Using negative intensity on lights doesn’t cast any shadow :confused:

Any idea ?

Thanks a lot for any help.

There’s no way to do that and shadow maps have the same limitation has lightmaps for stationary lights

That’s what I immagined :confused:

The last solution seems to be modifying Lightmass source code and editor source code to process only shadow mappings for specific lights, but I think lighting in Lightmass is not performed light per light, it may get all light data and process all of this in a custom logic …

I will check if I can found any clue on this in the source code.

If anybody has any clue on this don’t hesitate.


This solution is not a solution at all ^^

Shadow maps are just subtracted from lightmaps, so a static shadow is just an unlit area on the lightmap. No possibility to have shadow only. May be using a custom shader model would allow us to use lightmaps to darken these “unlit” area. I’ll take a look on this.

Stationary shadow maps are not subtracted from lightmaps. Lightmap has all indirect light from stationary lights and all lights from static lights. Stationary lights calculate direct portion of light at runtime and that is multiplier with shadow map data.

Just use Dynamic shadowing it should be pretty fast with new shadow map caching mechanic.

The problem is we can’t use stationary lights to make what we want, because we can have only 4 overlapping lights (we need more for our level design, we use high attenuation radius), and we can’t use dynamic shadow on movable light (too expensive).

@Kalle-H: when you talk about shadow map caching, you mean shadow map caching for stationary light with dynamic shadow or is it now available for movable light ?

Edit: If you talk about this Unreal Engine 4.13 Released!, I believed it was for stationary lights, it looks very interesting. I need to find why my movable point lights are not chaching shadow, they take a lot of performance to compute shadow each frame, it would not.

Thanks for your advice, I will work on this.

The caching seems to be performed, there must be a problem with my level, I spend 4.9 ms for shadow depth with 4 lights. May be some merge actors to perform, or too high trion meshes.

Use Movable lights. Don’t move them. Caching should make it plenty fast if most of the geometry is static/stationary.

I am testing this in a blank level with only cubes, indeed shadow depth has a very low performance cost. But now I have performance issues on ShadowProjectionOnOpaque, it takes between 1 and 2 ms per light when I am in fullscreen mode (no problem in viewport). I think I can’t ask ask my lights to consume less they can do ^^

You can still turn on/off a static light if that’s what you are looking for. You can use a static light and set its visibility to off at the beginning, the shadow map depends on the light’s visibility.

I need to progressively increase the light radius, turning on/off a static light would cause popping.

Set them visibility to false when they are not supposed to light the scene. Cost is related to amount of pixels they cover. Smaller radius is cheaper light.

So it must be because we have large rooms and large light radius. We already use level streaming for the lights to avoid lighting rooms that are not visible. I will try to limit lights radius or light numbers. Thanks for your advices.