Distance Field Indirect Shadows prototype

Hi, I’m Luoshuang. Just now I have finished DFIS for UE4. This idea is derived from Capsule Shadows directly, it extracts light direction information from indirect lighting cache, and generate indirect shadows by cone-tracing against distance fields.

GitHub: https://github.com/AlanIWBFT/UnrealEngine/tree/DFIS-4.14


  1. Currently tiled-culling is not implemented, so performance may be an issue.
  2. This technique shares the same drawback with RTDF: the umbra will always larger than what it should be (“over-occlusion”), So it will not always outperform Capsule Shadows.

Before enabling DFIS:

After: (all the objects have “movable” mobility)

Between this and your multi-lightmap solution, you’ve certainly got my attention, this is pretty impressive. Two questions actually, one about each project.

For this, does this work with fully dynamic lighting by any chance, or do you need to bake it down like in your github’s readme?

Also, for your multi-lightmap project, how scalable is it exactly? If I throw the multi-lightmap build at a scene around 16km large, would it work properly or do you find that for something like that, fully dynamic is still the better option?

  1. DFIS needs irradiance information from indirect lighting cache to work, but I think it may also extract irradiance from other GI solutions like LPV, PRT etc., of course you have to write it yourself…

  2. Multi-Lightmap Dynamic Blending has two major problems, one is storage size, another is light building time, so in my opinion it will not work in a huge scene.

PS: Since MLDB will also blend indirect lighting cache, so MLDB+DFIS can fake some ‘real-time’ GI.
PS2: MLDB can be seen as some form of PRT, but very limited.

This is really cool, especially that you used the object distance fields instead of the global distance field, since the global distance field is very low res.

I’m thinking the ray marching of mesh distance fields should be integrated with the capsule shadow tiled culling implementation rather than done separately with its own upsample. Conceptually a mesh distance field is just a different occluder primitive than a capsule, it sill has a bounds on its influence so it can be culled vs tile bounds in the same way.

The main downside of using mesh distance fields for indirect shadows like this is that you eat a large memory cost from enabling ‘Generate Mesh Distance Fields’ for the whole project just to get a few movable objects to cast. I’d probably add an opt-in on the UStaticMesh, much like you have to setup a USkeletalMesh for capsule shadows.

Thanks for the inspiration!

Thank you ! Will it come out in 4.14? :stuck_out_tongue:

Not sure, I haven’t started coding it yet =)

ok, had to log in just to say wow! This is what we need! Having characters with indirect shadows is awesome, but it’s a shame to see them interact with chairs for example that cast no shadow at all. Adding capusles for those is not pretty! This however is a very nice!
Like DanielW said, there should be an option to opt-in to specific staticmeshes.

Read the README.md on GitHub you will find that only meshes with “Distance Field Indirect Shadows” checked will cast indirect shadows. is talking about memory consumption when enabling “Generate Mesh Distance Field”, since current DF management is not specifically optimized for only a few objects.

Github DFIS-4.14: I added r.DistanceFieldIndirectShadowRayStartOffset to address some self-shadowing artifacts.

Now DFIS has entered the master branch! Thanks @DanielW !

This is awesome!!! :smiley:

Thanks for this! I’m gonna try it out soon.

FYI this didn’t make it in time for 4.14 =(

If you want to check it out early be sure to get cl 3186069 as well, that made the resulting shadows look a lot more believable.
“Using a weighted geometric mean to combine multiple Distance Field Indirect Shadows, greatly reduces over-occlusion when overlap is high”

This looks very interesting! Looking forward to seeing this as an official feature so we can start experimenting with it.

Distance Fields just keep amazing me on how much you can use it for…!

You can simply download the official master branch, DFIS is contained in it.

Just the master branch. https://github.com/EpicGames/UnrealEngine/tree/master
The master branch has no specific version, but now it should be 4.15

I’ve noticed that there are huge changes about distance fields on the master branch, e.g. complete refactoring of the df lighting system, performance improvements, and exclusive DFIS testing contents, etc. Since DFIS is already in 4.15 but not advertised in the changelog, may I assume that 4.16 would have a bunch of DF features? @DanielW

The large changes that will end up in 4.16 are entirely optimizations targeted around console performance, no new features introduced.

Profiling on PS4 1080p, Fortnite scene

4.3ms update global distance field with one large moving object
3.1ms RTDF shadows in range [4500 - 30k]
3.6ms DFAO

0.3ms update global distance field with one large moving object
1.2ms RTDF shadows in range [4500 - 30k]
2.6ms DFAO

Some old code paths and partially implemented features have also been removed (Distance Field Specular Occlusion, Distance Field Surface Cache AO, PreCullTriangles).

Thanks for the clarification!

I think this thread is dead, but isn’t this feature officially integrated in 4.18?