Easily add DLSS support in Unreal Engine titles through the official Nvidia Plugin. DLSS provides major performance improvements.
www.tomlooman.com
Last year Nvidia announced DLSS 2.0 with the ability to open this new anti-aliasing solution for all games. The game-specific deep learning is no longer required as it was with prior iterations. For an indie dev that is especially exciting as the chance of getting onto Nvidia’s SuperComputer was pretty slim.
Besides the new game agnostic algorithm, we also get much-improved anti-aliasing results which honestly looks pretty fantastic and somewhat unbelievable in games like Control (See
Digital Foundry’s DLSS Comparison). You’ll get a chance to see how DLSS performs in Unreal Engine through my own experiments below.
For testing, I used my open-source
SurvivalGame (available on GitHub) and
Dekogon Studios’ City Subway Train asset.
SurvivalGame on GitHub received a graphical refresh for this DLSS Test.
What is DLSS?
DLSS stands for
Deep Learning Super Sampling and in the 2.0 iteration it can use the Nvidia RTX cards’ Tensor Cores to upscale lower resolution render buffers to the desired ‘native’ scale much better than any
existing upscale algorithm inside UE4 currently. At the same time that DLSS upscales, it is performing anti-aliasing effectively gaining performance from rendering the scene and post-processing at reduced input resolution. This AA solution replaces TXAA and so dithered materials don’t seem to render the same with DLSS currently (where TXAA would soften the dither pattern).
Remember that aliasing itself occurs from rasterizing a scene to pixels. Fewer pixels will cause higher aliasing, so the fact that DLSS actually fixes most aliasing while we provide it a much lower input than native is pretty amazing if you ask me.
Even Zoomed-in you can barely see the difference. (but there is a big gain in performance, some numbers further down)
One title using DLSS to improve performance while maintaining visual fidelity is Deliver Us The Moon, built using UE4.
Getting Started
For this article, Nvidia hooked me up with an RTX graphics card and access to the
Unreal Engine RTX/DLSS Branch on Github. With the new graphics card, I got to play with ray-tracing for things like shadows, reflections, ambient occlusion, and even full Path Tracing that is now available. But what excited me most in practical terms is DLSS 2.0 and it has been the least covered in the context of Unreal Engine.
So what does it take to get DLSS running in your Unreal Engine project? Well, for now at least you need an AppID provided by Nvidia (
must apply to receive an AppId) to enable the tech along with the custom engine modifications on GitHub. I suspect this to get easier in the future, but at least I can already show you what you should be excited about in case your studio can’t get access to it just yet.
Once you do have those pre-requisites figured out – it’s pretty straightforward to get up and running (So long as you know where to look).
Here are the required steps to make this process easier for you:
- Associate and compile your project with the UE4 RTX Branch
- Make sure the “Nvidia DLSS” Plugin is enabled via Edit > Plugins…
- Add the AppId provided by Nvidia in Config/DefaultEngine.ini (See Below)
[/Script/DLSS.DLSSSettings]
NVIDIANGXApplicationId=XXXX
- Enable DLSS by calling UDLSSLibrary::SetDLSSMode(UDLSSMode) (Available as Blueprint node) or “r.NGX.DLSS.Enable 1”
- (Optional) Tweak the desired Sharpness with UDLSS::SetDLSSSharpness(float) (Or Blueprint variant) between 0.0 and 1.0 (0.35 seems to be the recommended value)
The internal resolution is downscaled automatically based on the DLSS quality-setting. You can choose between 5 modes from
Ultra Performance, Performance, Balanced, Quality, and
Ultra Quality (Although this last mode was ‘
not supported‘ for my setup). Finally, you have the option to sharpen the output.
Helpful (UMG) Widget to display and test DLSS. (from Nvidia Branch)
In my tests, the internal resolution can go down to 33% (in
Ultra Performance, meant for 4K Displays) which is a huge saving in screen-space operations such as pixel shaders, post-processing, and ray-tracing in particular. Even at 50% for Performance & Quality modes it’s still x4 fewer pixels to process. Judging from the provided UI the internal resolution can change on the fly between a predefined range (eg. from 50% to 69% in Quality-Mode) I’m not sure at this time how DLSS decides which exact internal resolution to use.
Zoomed view of 1440p at 50% (r.ScreenPercentage 50, no AA), this is the input data that DLSS has to work with.
Anti-Aliasing Quality (DLSS vs. TXAA)
The default anti-aliasing solution for Unreal Engine is TXAA (although FXAA is supported with inferior results) and so this is the main competitor for Nvidia’s DLSS in the engine.
Since DLSS is using a lower internal resolution, the real test is whether it can maintain final image quality while improving performance. A second major benefit for DLSS is how it scales to 4K Displays (unfortunately my monitor is only 1440p) as it can enable 4K Gaming on mid-range graphics cards by using a more reasonable internal resolution.
It’s telling that often I had to double-check the screenshots to make sure I had the correct one between TXAA and DLSS. Below you’ll see a few zoomed-in comparisons so that image resizing can’t interfere and honestly it’s necessary in order to see the difference.
Trees even look crisper on DLSS than native TXAA. Cables hold up incredibly well, slightly harsh in places, mainly noticeable due to zoom-level.
Left: 1440p TXAA, Right: DLSS Quality-mode (Zoomed)
Nearly indentical quality, slight error in the ceiling lights where a white line in the original texture got blown out by the DLSS algorithm causing a noticable stripe. I reckon this should be ‘fixed’ in the source texture instead.
Left: TXAA 1440p, Right: DLSS Quality-mode. (Zoomed)
Reflections look ever so slightly different, this scene used ray-traced reflections on highly reflective materials.
DLSS vs. TXAA Performance
For the quality and performance comparison I’ve made a quick video toggling between the 3 different AA modes (TXAA, DLSS Quality & DLSS Performance) to see the difference. As you’ll notice the visual quality is often difficult to see while the framerate takes a big leap at the same time. I would even argue that DLSS Quality-mode can conjure a higher quality image in some cases (I found that my foliage scene ‘felt’ crisper with DLSS enabled).
(Make sure to watch in 1440p and fullscreen.)
The Numbers
Please keep in mind these numbers were taken from my unoptimized scenes, running in standalone-mode (outside the editor) but not a cooked build. Several RT features were turned on to strain the system (including raytraced reflections).
Forest Scene (RTX On 2560×1440)
Forest Scene (Note: Downscaled JPG from 1440p source)
This scene was likely bottlenecked by the ray-traced reflections and so you’ll see a huge gain in framerate as the internal resolution lowers from DLSS.
- TXAA Baseline ~35 FPS
- DLSS Quality ~56 FPS (+60%)
- DLSS Balanced ~65 FPS (+85%)
- DLSS Performance ~75 FPS (+114%)
- DLSS Ultra Performance ~98 FPS (+180%?! – Noticeably blurry on 1440p, intended for 4K)
Subway Train (RTX On 2560×1024)
Subway RTX On (Note: Downscaled JPG from 1440p source)
The camera used a cinematic aspect ratio hence the 1024p height. This scene used similar RTX settings and even ray-traced ambient occlusion on top.
- TXAA Baseline ~38 FPS
- DLSS Quality ~69 FPS (+82%)
- DLSS Performance ~100 FPS (+163%)
Subway Train (RTX Off 2560×1024)
Subway non-RTX (Note: Downscaled JPG from 1440p source)
Without any further RT-options enabled the difference in performance between internal resolutions appears to diminish somewhat. Although this was just a single test and your mileage may vary (as with all performance metrics, GPUs are a complicated beast)
- TXAA Baseline ~99 FPS
- DLSS Quality ~158 FPS (+60%)
- DLSS Performance ~164 FPS (+65%)
DLSS Render Pass
The DLSS-pass occurs during Post Processing much like traditional AA solutions. On my
Nvidia RTX 2080 Ti the cost to upscale to 1440p was about 0.8-1.2ms. This number seems to be consistent regardless of DLSS-mode, For reference, TXAA at full 1440p costs about 0.22ms on my machine.
ProfileGPU Output Window.
You can measure performance of individual render passes by either using “ProfileGPU” or “stat GPU” console commands.
Performance Conclusions
The performance potential of DLSS is huge depending on your game’s rendering bottleneck. Reducing internal resolution by 50% has an especially large benefit on RTX-enabled games with ray-tracing cost highly dependent on resolution.
Ray-tracing features appear to be working better with DLSS enabled from a visual standpoint too. RTAO (Ray-traced Ambient Occlusion) specifically causes wavy patterns almost like a scrolling water texture when combined with TXAA. However, Enabling DLSS above Performance-mode completely eliminates these issues and provides a stable ambient occlusion.
Conclusion
Throughout my experiments, I’ve been super impressed with the results of DLSS 2.0. The fact that this magically works on any game out of the box without Nvidia SuperComputer pre-processing is impressive.
The image quality remains high and sometimes even managed to be crisper than TXAA. There are some artifacts I ran into, that were overall small compared to the large performance gains we saw across the board. I’d love to test this on a 4K Display which is where DLSS can shine even more.
For now though the DLSS Branch of Unreal Engine isn’t widely accessible and you’ll need to contact Nvidia to get access.
If you want to see more,
follow me on Twitter and
Subscribe below to receive new articles straight to your inbox!
References