Distance Fields in Unreal Engine

http://www.tomlooman.com/distance-fields-unreal-engine/

Distance Fields in Unreal Engine

Posted on October 10, 2014 by Tom

Unreal Engine leverages the power of Signed Distance Fields for Ambient Occlusion and more recently added Ray Traced Distance Field Soft Shadows. I will briefly discuss and demonstrate both effects as a result of some early research to consider using these techniques for our game. Since the core of Switch’s design hinges on fully dynamic levels, we simply cannot bake down any lighting. As a result we have to look out for a better approach to create scene definition and toning that is both fully dynamic and lightweight enough to run on a wide range of PCs.

Distance Field Ambient Occlusion

The Unreal 4.3 release introduced Distance Field Ambient Occlusion using a Signed Distance Field. The basic principle of a distance field is that it represents the distance from the object to the point in the the grid. ByteWrangler has a nice and simple explanation on distance field in 2d if you’d like to know more. To better understand how DFAO can be of use for Switch I did some setup & research using the Unreal examples and some of the meshes we currently have available for our project.

Unreal 4 Mobile Demo Scene

Detail Lighting Mode, DFAO Disabled

Detail Lighting Mode, DFAO Enabled

DFAO In Switch

A quick test on the meshes we use in Switch revealed mixed results, mostly due to open mesh hulls which the documentation pages do mention may cause issues. Our test wall which is completely triangle sealed did provide much better results.

Editor AO-only visualizer

Issues & Performance

At it stands the effect is quite a burden on the GPU (See documentation for performance measurements) and the impact was very noticable when first using this in a full level. I will keep an eye out for upcoming updates to Epic’s DFAO and revisit this in the future once we got our new art. Until then SSAO and baked self-occlusion maps are a good alternative for us.

Ray Traced Distance Field Soft Shadows

The preview release of 4.5 introduced Ray Traced Distance Field Soft Shadows to the Unreal Engine, while I am not aware of the full implementation details, I can show you the practical effect in-game using the Sun Temple & Effects Cave examples from Unreal.

The image below illustrates the basic goal of the soft shadowing technique, hard shadows near the caster that slowly soften as they get further away. This adds an incredible amount of shadow quality using a simple checkbox and can work wonders on your long normally low detailed directional shadows too when using high frequency details like rails.

unreal 4.5 ray traced distance field soft shadows

Sun Temple

Soft Shadows Disabled

One thing that stands out in the Sun Temple demo is the increased quality of the pillars on the right side, using soft shadows you get a much more accurate result.

Effects Cave

Soft Shadows Disabled

Soft Shadows Enabled

In the final test I enabled soft shadows in the Landscape Demo and did not encounter a huge difference there. Primarily more accurate shadows on the rocks and bridges so I left it out.

Visualizing Distance Fields

The editor supports some cool visualizations, be sure to check the “Mesh DistanceFields” (shown below) when working with DFAO or soft shadows. The “DistanceField AO” visualizer only displays the generated AO as seen in the test wall comparison image above (under “DFAO in Switch”)

DF_Menuoptions

Limitations

The official documentation lists several limitations and future improvements for DFAO. What struck me the most is the current GPU cost of the technique, 4.5ms vs. 0.6 ms of SSAO on a 7970 at 1080p. This is fairly high and I did notice an immediate drop in performance when doing some initial tests on Switch. With the effect being used in Epic’s very own Fortnite I hope they will continue to improve upon the technique and hopefully find some performance gains along the way.

The Ambient Occlusion technique does not work flawlessly for all situations and models, I recommend giving it a try when you have a good representation of your final geometric style and see if this technique is well-suited. The same seems true for Soft Shadows and I’ve found a few cases that yielded undesirable results. The angel figure in the Mobile demo is a good example where Soft Shadows did not yield the expected results. Skeletal Meshes do not work with soft shadows and as a result don’t display a shadow at all (You may notice that they will not show up in the Mesh DistanceField visualizer either)

SoftShadows_Artifacts_Comparison

Update: To resolve the shadowing issues above the distance field resolution map should be increased. More info on the official docs page.

Further Reading

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值