RayTraced DistanceField shadow leaks

Hi there,

I’m having some issues with large differences between CSM and distance field shadows for directional lights, making for severe lighting artifacts when the camera moves. In particular, I have a ton of skyscrapers forming a city, and the distance field shadows are giving me a lot of light lighting at the base of the buildings, as well as missing about a third of the height of the buildings. When for instance moving down a street, this means I’m fading in these light leaks with the camera distance.

Is there a way around this? I have tried increasing the distance field resolution, but as far as I can tell, it doesn’t seem to help. Is there a approach to shadowing sunlight for a cityscape scene meant to be seen both from above (fly overs) and from POV at street level?

I have attached screenshots from a contrived example illustrating the issue, with two cubes (scaled to match skyscraper dimensions) and one of my assets. There are two directional lights in my scene: one green light using only CSM, and one red light using only ray traced distance field shadows, and you can clearly see the mismatch. When I move the camera closer to the ground, the shadow quality at the bottom increases, but the missing height remains.

Thanks,

Missing height is due to the size limitation of ray traced shadows. You could increase it via the source code but i dont know how. Quality of the bottom should be fixed by higher mesh resolution but you say you’ve already tried that so i dont know.

Hi Nordahl,

Jacky is correct that there is limitations with Distance Fields. For larger meshes it’s best to break this up into smaller pieces as the volume textures for DFs don’t scale well with larger objects. This will lead to seeing the shadow tiles culled like this. This is a performance optimization.

It’s also unlikely that on a larger object like that this that increasing the resolution of the DF will help that much.

Distance Fields work really well with uniformly scaled modular style meshes. Keeping these meshes a moderate size is also needed.

I hope this helps.

Tim

Hi Tim,

Thank you for the answer. A couple of follow up questions:

Could you clarify what you mean by “moderately sized meshes”? Is this in terms of world space units, or poly density? What’s a good range for a “moderate”? Would it be possible for us to change what “moderate” is to be larger? (for instance by changing a magic number and recompiling).

If we were to split up our skyscraper assets into smaller chunks with more uniform bounding boxes, what would be a good way to approach this from an asset management standpoint inside of Unreal? Ideally I’d want to wrap that complexity into a black box, and enable environment artists to treat a skyscraper as a single asset rather than the individual pieces. Is there a “collection” type of mesh which can reference multiple other meshes, or would this be a Blueprint kind of thing?

And lastly - just to be safe - is raytraced distance field shadows even the right approach for sunlight shadowing in a cityscape style environment, or am I on my way down the wrong rabbit hole here?

Thanks,

Larger meshes tend to have more errors than smaller meshes with Distance Fields. So ideally, if you’re seeing DF issues with your mesh it would be better to try increasing the DF resolution in the build settings. This will only work to a certain point. At that point, it would be better to break the mesh down to a smaller chunk.

Using a game like Fortnite, which uses these extensively can give you a good idea of the scale being used by EPIC. You can see some reference images in this page.

This post also explains some of the issue with larger meshes.

Something like a sky scraper would just need to be broken up into several chunks that can be used assembled in the editor. Going back to Daniel’s posted linked above, large objects are just not going to work well.

For the multiple pieces, you can either group them or use a BP to treat them as a single asset.

There are limitations to the number of meshes in your view that can use DFs at a time. This is a D3D11 limitation and not just an arbitrary one. If you’re using a combination of DFs and Cascaded Shadow Maps (Default), you can use DF shadows on your more distant meshes and turn off “Affect Distance Field Lighting” in the Details panel for smaller meshes that may not need them when cascaded shadows are within range.

I don’t think you’re going down the wrong rabbit hole here, it’s just a matter of working within the limitations of the system. I wouldn’t personally approach a project as only using Distance Field shadows and disabling CSMs. They can work well together to get a good look and provide shadowing at further distances.

Thank you very much for the thorough answer, Tim. I’ll take a look at the links and adjust our workflow accordingly.

I don’t suppose you could take a look at my other post as well, which is about some challenges I’m having with getting CSM to look good?

Thanks,

I’ve gone ahead and assigned myself to that one as well. I’ll post once I get more time to look at it.

Just a heads up though, if you’re planning to use DFs with VR, if I recall DFs don’t work with VR, at least not at the moment.

Thank you, Tim!

That’s okay, our “VR” isn’t really VR, but realtime renders for interactive TV.

Tim,
Increasing the resolution we can receive max 128x128x128 resolution scale. There is any way to increase this value to 512x512x512. I see the performance cost is very low. Increasing to 3x512 increase performance cost but maybe not much like cascades. This is great solution for modular levels! Have You got any news about that? In 4.13 contact shadows coming. Are You stop developing the distance fields?

Tim,
Increasing the resolution we can receive max 128x128x128 resolution scale. There is any way to increase this value to 512x512x512. I see the performance cost is very low. Increasing to 3x512 increase performance cost but maybe not much like cascades. This is great solution for modular levels! Have You got any news about that? In 4.13 contact shadows coming. Are You stop developing the distance fields?