How do distance fields get generated and how do they differ from the actual geometry?

Hi @Sailor_Neptun,

This is a really great question! I’ve done some research and this is what I’ve come up with:

The simple answer as to why Lumen uses Mesh Distance Fields is to support software ray tracing on as many platforms as possible. The alternative, hardware ray tracing, is very hardware-dependent, though it does generally give better results as it does traces against the actual geometry. Software ray tracing is more performant, while hardware ray tracing provides higher-quality reflections. Basically, software ray tracing uses mesh distance fields to approximate the shape of the meshes, while hardware ray tracing uses the actual mesh.

As for what exactly distance fields are, they store the mesh’s distance to nearest surface within a volume texture, which allows Lumen to do mmathematical “traces” against these volumes to determine lighting instead of having to actually do a bunch of raycasting. This comes with some upfront cost though, since all of this information has to be stored ahead of time.