Mesh distance fields for better shadows

I have been going through unreal engines documentation and what they did on fortnite for getting some smooth shadows. they use mesh distance fields in which they create a 3d texture of every mesh at different scales and then use that to approximate the shadows being cast. In comparision to traditional ray based shadow casting it has about 20-25 perfomance gains at the cost of using additional memory. can we do this on webgl or are there some serious issues with trying to implement this in babylonjs.
link to unreal engines mesh distance field

Mesh Distance Fields

I guess it should be possible to implement this, as it seems it uses 3D textures that are available in WebGL 2. Now, I’m not sure there’s enough information in the Unreal doc to properly implement the technic…

Theres an chapter in gpu gems on signed distance fields. which is the real basis for mesh distance fields in unreal engine.


Theres also a link in the references in unreal engines documentation that links to a website on raymarching SDFs
https://iquilezles.org/www/articles/raymarchingdf/raymarchingdf.htm

That could do it, PR are always welcome :wink:!

1 Like