RTGI TLDR (realtime raytraced global illumination cheat sheet)

UPDATE: 4.22 is out of Preview, please see official docs:

Ray Tracing Overview:
Ray Tracing Settings:

The information below may still be useful for tweaking/troubleshooting…

I’ve been playing a bit with the new realtime raytracing features in UE 4.22 Preview Release, and wanted to share a quick visual guide for those looking to start playing without digging for information. Note that this information is culled from several sources, including:

… and a number of other sources – please check those places for further detailed information and other developers’ experiences.

See also this excellent talk/walkthrough by Epic’s Sjoerd De Jong from GDC:

Example of RTGI in action with single directional light:

Example with directional light, multiple rect lights, mutliple point lights, and several multibounce fully reflective mirrors:

RTGI cheat sheet:

  1. Most importantly, you MUST have Windows 10 version 1809 to enable Microsoft’s DirectX 12 DXR API (no earlier Windows versions have this), and you must have an Nvidia RTX GPU and recent Nvidia drivers installed (these are the only GPUs supported at the moment). In theory this tech could work on other operating systems, and other GPUs, but no one has written the APIs and drivers to make it possible (yet).

2. Download Unreal Engine 4.22 (currently Preview Release) in the Epic Launcher, and create a new shortcut to this version on your desktop:

3. Right-click this new shortcut and click “Properties” to change the command line – after “UnrealEditor.exe” you need to add a space and “-dx12”, then click OK to save the shortcut. Only use this shortcut to open the editor from now on, or the raytracing features won’t be available.

4. In the Unreal Editor, create a new project, or open an existing project. In your project settings, enable “Raytracing” under the Engine section – as of recent Preview Release versions, you will then be prompted to also enable “Support Compute Skincache” to allow Raytracing to work.

5. Restart the editor for the raytracing setting change to take effect.

6. Once your project is open again, go to the console (I like to go to Window → Developer Tools → Output Log to display the output log window, then dock this window in your layout to easily enter console commands and see the output). Enter “r.raytracing” to confirm that raytracing is enabled – it should display “r.raytracing=1” – If not, none of the below will work, and you need to solve this first. As long as you’re using Windows 10 1809, a supported GPU (Nvidia RTX at the moment), using the -dx12 shortcut you created, and enabled the above settings, you should get this far.

7. The rest is simple: in the editor command console, you can start typing “r.raytracing” to see most of the exposed parameters you can change in a popup – enter any of them WITHOUT entering a value, then press enter, to see what the current setting is (the default settings may change with subsequent engine versions). You can see a complete list of settings (including some that don’t start with “r.raytracing”) in the Raytracing Overview PDF.

8. By default in UE 4.22 Preview 4, it appears all raytracing features are enabled EXCEPT global illumination, so enable that by entering the console command “r.RayTracing.GlobalIllumination 1” (note that you need to enter a space before the value for each command, although the output will display an equal sign, and you would use an equal sign to set these parameters in INI config files).

9. Note regarding dynamic shadows: It appears that cascaded shadow maps remained enabled for my directional light even with raytraced shadows enabled (this may have been a bug specific to my case and an early Preview build) – I’m not a fan of the look of dynamic cascaded shadows to begin with, but in my case they looked especially strange combined with the much better raytraced shadows, and in any case aren’t needed, so be sure to check your light sources’ shadow settings and DISABLE cascaded shadows by setting them to zero if this happens to you:

10. Default raytraced global illumination is quite blotchy and rough in areas that are indirectly lit. Experiment with various combinations of “r.RayTracing.GlobalIllumination.ScreenPercentage” (default 100) and “r.RayTracing.GlobalIllumination.SamplesPerPixel” (default 1) to find a more pleasing look while maintaining decent performance. For roughly the same performance as the default settings, but much smoother indirect lighting, I used “r.RayTracing.GlobalIllumination.ScreenPercentage 25” to reduce the raytracing computation overhead, then “r.RayTracing.Globalllumination.SamplesPerPixel 32” to greatly smooth out the blotchiness. This worked much better in my case than the alternative of keeping r.RayTracing.GlobalIllumination.SamplesPerPixel low (even at the default 1), and increasing r.RayTracing.GlobalIllumination.ScreenPercentage to, say, 150 or more (which still looked very grainy, while bringing framerates much lower).

11. When Playing In Editor (PIE), your console commands entered above will be used, but note that if you preview in Standalone mode, or make a packaged build, you’ll need to use the -dx12 command line parameter to enable raytracing features. You can create a shorcut to your packaged build’s EXE similar to how you made the editor shortcut above, and for standalone preview, you can change the “Additional launch parameters” in Editor Preferences:

UPDATE for black sky bug: If your skybox is completely black (this started appearing for me in 4.22 Preview 5, other experienced it in earlier versions), try entering the console command “r.GlobalIllumination.Denoiser.HistoryConvolution.SampleCount 1” to work around the issue:

Thanks to @estudioae for the fix!

UPDATE for editor crashing after enabling Raytracing in Project Settings then restarting (this appears to be a common problem with 4.22 Preview 6): if after you first enable Raytracing in your project’s settings, then restart then editor in DX12 mode (using the shortcut above), your editor crashes on loading your project… try loading your project from the Epic Launcher (without the DX12 option) just once to allow it to recompile all shaders, then when this completes close your project and reopen it again using the DX12 shortcut.

Thanks to @Jhosep_Chevarria for the fix!

UPDATE new global illumination performance-affecting console command in Preview 7: a new console command was exposed in Preview 7 – setting this to 1 instead of the default 2 increased my framerate significantly with no visual difference

r.RayTracing.GlobalIllumination.NextEventEstimationSamples (default value 2)

Good luck!

I hope it gets fully integrated soon in the Editor like any other featureset with normal menues and so on.

Brilliant video, thanks a lot for the rundown ! :slight_smile:

Thanks! Here’s another one I put together over the past few days, with a directional light, multiple rect lights, point lights, and multibounce reflective mirrors:

Unsurprisingly, performance drops a bit versus the previous video (which was a single directional light), but this is really promising if it’s any indicator of where the next few engine versions will take us.

It’s already really productive to work in despite some showstopping bugs – I’ve run into apparent GPU VRAM leaking which eventually bring performance in-editor to a halt, and occasional crashes when opening/previewing certain materials (although no problems using those same materials in the viewport or in-game).

Looking forward to seeing what other (more skilled) people make with this tech!

How did you set up your lights if you dont mind me asking? I cant seem to get the same effect when i use rect lights inside 2 hemispheres. My material completely lights up whilst yours seems to stay dark, and i also get a dead straight seem where the back of the rect light is. I am using 2 rect lights facing back to back in the centre of the 2 hemispheres.

I got it. I’m not exactly sure what the problem was, i think it was my normals, and also ue needing a restart :confused:

If you’re doing something similar to the two paired hemispheres in the second video, I just used a blueprint actor with a single mesh object (with a flat slice subtracted from the middle, then another smaller sphere subtracted to hollow it out), and a single point light right in the middle parented to the mesh, with a source radius greater than zero to make soft shadows from the light projected through the opening.

I only used four rect lights in that scene, each in front of the four tall black rectangles (two in the starting area, and two in the later area with the mirrors), that emit the intermittent flashing light.

The part about the black skybox just happened to me, and I have a fix that worked for me hopefully you aswell. Not just the skybox but everything in my scene went super dark, including if you went into a static mesh in edit mode. What I had done that caused this was auto exposure, I had set mine to manual and selected min and max of 1 and 1.2. But after saving my scene and later restarting the scene was completely black. I went through a panic trying to figure out what I thought had to be something I had done, but low and behold my auto exposure settings had changed to -10 20, instead of 1 1.2. I hope this helps you all. Because it freaked me out. If this happens to you dont go willy nilly changing your lights around instensity and so forth, as there probably fine.

Since this uses DXR, does it mean it’s not CUDA specific and should work on AMD’s new GPU Lineup? (6000 series)

If those cards support DXR then yes

Edit: Looks like the answer is yes