UPDATE: 4.22 is out of Preview, please see official docs:
Ray Tracing Overview: https://docs.unrealengine.com/en-us/Engine/Rendering/RayTracing
Ray Tracing Settings: https://docs.unrealengine.com/en-us/Engine/Rendering/RayTracing/RayTracingSettings
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:
- the 4.22 Preview thread
- the ArchViz 4.22 Raytracing Overview thread (especially the helpful PDF linked therein and this post by Tim Hobson outlining current features and limitations)
- this dev-rendering branch merge thread
… 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:
- 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:
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.
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)