Distance Fields and Ray Traced Shadows

Hey, I’ve been reading a lot about DFAO and Ray Traced Soft Shadows but I’m still not really sure of when they should be used.

Are they something that should just be used with dynamic lighting and scenes? Or are they usable with static lighting too - or a mix of the two?

For example, an interior space with mostly stationary lights baked with Lightmass, with some dynamic lights which the player can turn on and off.

I assume Ray Traced Soft Shadows will be useless on the stationary lights, but work well for the lights the player can interact with? I also assume that DFAO would be useless in this circumstance.

However, are Ray Traced Soft Shadows useful for large-ish landscapes with baked lighting, to mix with the Cascade Shadow Maps?

Sorry for all the questions, despite reading all of the documentation - I still am unsure of actual use cases for these techniques.

Thanks in advanced.

I made a presentation just for you!

Probably more technical than you are looking for, but answers a lot of those questions.

Any news about just switching to only tracing the global distance field and thus boosting performance a lot? I mean, for detail you’d have to store global at a higher resolution than now, but as long as you’ve got like, .125 or even .2 meters as the min resolution (min Z camera distance dependent) anything smaller could easily be filled by SSAO…

I wonder if there’s some clever way to do “negative” SSAO to correct for low res SDF overoccluding? Edit- Also, parallel uniform tracing a global SDF could be a huge win for distant shadows.

The problem with using the global distance field is that it’s really only acceptable to sample it far from surfaces due to the low res. But when you’re doing RTDF shadows you don’t usually sample the DF far from surfaces, the cone being traced to the light is extremely tight and all objects have been preculled carefully to the receiver. So far I haven’t been able to see a way to leverage the global DF for shadows.

Hmmm, the resolution might be too low for global and direct shadows. But just looking at the numbers for indirect shadowing, there’s no reason to do per object for that. You decide the texel (voxel? whatever volume nomenclature is) resolution for global distance fields. Uniform GPU access to a single data structure has to be faster than accessing multiple per object structures, and since it’s occlusion only I don’t see memory as being a problem.

Thanks for the presentation, it answered a lot of questions I was about to ask! But I do still have one problem. In the Kite Demo CSM were replaced at a certain distance with Distance Field Shadows, but in Fortnite, Distance Field Shadows seem to be active 24/7. I understand why the Kite Demo used CSM at close range, but as for Fortnite… I’m a tad confused. In engine, Ray Traced shadows are only active on Epic quality. So if you set a movable Directional light to use them instead of CSM, then on all lower qualities, you lose all shadows. Is there a way to make the engine switch between the two based on quality settings? Because Ray Traced shadows look fantastic up close for most uses, and I would like to use them in that way.

Oh yeah the global DF IS used for DFAO. That’s what I made it for originally actually, where I got a ~4x speedup.

It’s been a while since I looked at Fortnite so I can’t verify, but that’s certainly not the intention. CSM is supposed to be used near the viewer for World Position Offset support and so that on mid spec we still have shadows.

Thank you for the link. Very interesting read…although I’m not sure if it answered my questions.

Or, I didn’t understand enough of it for it to answer them, anyway. Rendering / technical art certainly isn’t my expertise.

I get from the PDF that it is very useful for very large, open-world games where lightmass would require massive amounts of memory to store lightmaps. In this case Cascade Shadow Maps would be used for up-close up object shadowing to retain the animated shadows, whilst Distant Field Shadows would be used for the distant areas. What about smaller scale landscapes with baked lighting, however?

I’m still unsure on using it in the scenario I outlined. A fully indoor scene with no directional light - just baked lighting with the odd movable light, which the player can turn on or off.

Also, I should apologize for the word “useless” in my original post. Of course, distant fields are fascinating and useful tech that has had a lot of work put in to it - what I meant was not viable in this specific scenario :slight_smile:

If you don’t have dynamic time of day and the level is mid-sized or smaller, just use a Stationary directional light. It will have baked shadows which are very efficient and high quality.

If you need dynamic shadowing from the sun (time of day, or level is Kite demo huge) then use CSM in the foreground, RTDF shadows in the distance.

Thank you very much for the reply. Sorry you had to spell it out for me!

I’m a bit confused bit DFAO. It says in the doc that ‘‘Only Static Mesh Components, Instanced Static Mesh Components, foliage and landscape are supported for causing occlusion.’’ but baking a whole forest is a pain. I thought it could be used for movable foliage.

What would be the best way to make a realistic forest with all movable trees on an overcast day (without direct sun) and still have some sky occlusion. I’ve manage to do something decent with a static skylight+hdri and a very very weak directional light and by adding a bit of AO in the post process volume. I feel like it’s not dark enough under by huge snow covered firs tho!!!

It can be used for foliage, you just have to opt-in and enable bAffectDistanceFieldLighting on the foliage settings.

The terminology ‘Static Mesh Component’ means rigid meshes. Static Mesh Components can have Mobility of Static or Movable, DFAO handles both with no baking because it is fully dynamic (confusing I know).

DFAO

How does DFAO handle shadows of distant landscapes that are casting very near to the camera (think very long shadows near sunset)? Or should I continue to crank up far CSM for that?

Distance Field Ambient Occlusion is not shadowing of a directional light, it’s shadowing of a sky light.

Ray Traced Distance Field shadows is shadowing of a directional light (or point, or spot). However, RTDF shadows don’t support landscape atm.

What you have to do is setup a few ‘Far’ cascades with FarShadowCascadeCount and FarShadowDistance on the directional light. Landscape renders into the Far cascades by default, nothing else does. You can include large static meshes in the Far cascades by enabling bCastFarShadow.

This is how the Kite demo was done.