Michelangelo Cellini showed how to make the most out of the new real-time ray-tracing features in UE4.
Introduction
In this tutorial, I will showcase the new ray-tracing features made available to all users in Unreal Engine version 4.22.2. To compare the changes introduced by ray-tracing I have built from scratch a unique environment that includes a variety of materials and modular assets.
I am always excited to share my discoveries on new software and techniques, and I feel like ray-tracing is a great tool that can give you greater control over the visual aspect of your scenes.
I will personally continue experimenting with these features and I hope to see them integrated into more games and projects in the coming years, as well as wish for continuous support from hardware manufacturers to the development of amazing technologies like these.
Step 1: Basic Requirements and Setup
To enable ray-tracing in your project you will need to install Unreal Engine version 4.22.2 (or newer), Windows Build 1809 (or the most recent update) and an Nvidia graphics card (either RTX or 10 series) with the latest drivers installed. Not all the 10 series cards are currently supported, check Nvidia’s official website to see if yours is compatible.Step 1: Basic Requirements and Setup
Inside the Engine, in the Project settings force DirectX mode, enable ray-tracing and enable skin cache if you haven’t already, then restart the engine.
Step 2: Ray-Traced Shadows
Ray-tracing should now be enabled in your project. If you had any pre-existing lights in the scene make sure that Cast Raytraced Shadows is enabled in the light’s Details panel. Any newly created lights will have this setting enabled by default.
I decided to lit my scene with a single directional light to be as true to a real-world scenario as possible, where the ruins would be lit by the sun only.
Step 3: Shadows Control
To control the sharpness of the shadow, change the Source Angle (or Source Radius) in each light’s Details panel: a higher value will result in a softer shadow.
Notice how the shadows are progressively softer the further they are from the contact point between objects, just as in real life.
Step 4: Post-Process Volume
All of the new ray-tracing features can be controlled either through Console Commands or the Post-Process Volume. To use it find it in the Volumes tab in the Modes panel and drop it in the level. Then set the volume’s boundaries to Infinite Extent to affect the whole scene or scale it to your preference.
Step 5: Ray-Traced Reflections
After enabling ray tracing, the reflection type has been changed. As you can see in the screenshot, all of the elements that are present in the level appear in the reflection on the globe on the right, despite being outside the frame.
Ray-traced reflections have a very big impact on performance but, there are many ways to reduce their computation cost.
Step 6: Reflections Control Max Roughness
To improve performance we can limit the number of reflections that are going to use ray-tracing by setting a limit in the Ray-Tracing Reflection section inside the Post Process Volume. In the Details panel, look for Max Roughness, (set to 0.6 by default) in my case I lowered it to 0.2 since I don’t have many materials that require accurate reflections. To visualize the roughness values in your scene you can switch to Roughness in the Buffer Visualization dropdown menu at the top of the Viewport. To go back to the default view mode press Alt+4.
Step 7: Ray Distance
To further improve performance, we can limit the distance that the rays that are scattered throughout the scene to trace the reflections will travel. We can do this thanks to the command “r.RayTracing.Reflections.MaxRayDistance”, where the input value indicates the distance from the camera. By lowering the value, objects further away from the camera will not show up in the reflections. As you can see in the screenshots, after lowering the value to 3500 units, the temple in the distance is no longer visible in the reflections.
Step 8: Reflection Control Max Bounces
The Max Bounces setting sets the maximum number of bounces that the reflections use. In my scene, increasing the value to 2 allows the reflections that affect the stone trim to be reflected on the golden artifact, if you have multiple highly reflective surfaces in your scene this change would be even more drastic.
Step 9: Reflection Control Sample per Pixel
Increasing the sample per pixel improves the accuracy of the reflections. In my scene, the reflected shadows get slightly brighter and are not pitch black if I raise the samples per pixel to 4.
Step 10: Reflection Shadows Control
This setting has 3 options here illustrated in my screenshots. I found Area Shadows to look quite noisy in most cases, but their quality can be improved by tweaking the previous settings.
Step 11: Reflection Denoiser
This feature allows for fewer rays to be used for computation by intelligently refining the final ray-traced reflection output. The denoiser is enabled by default, and you can disable it with the command “r.Reflections.Denoiser 0”.
Step 12: Ray-Traced Ambient Occlusion
The Ambient Occlusion type can be changed from the Post Process Volume’s Details panel as well. The ambient occlusion looks more intense using the default settings but additional controls allow the ray-traced version to be more apparent too.
Step 13: Ray-Traced GI
Ray-traced GI is dynamic and reacts beautifully to real-time material changes. Enabling this setting in my scene drastically improved the quality of the shadows and the realism of the materials. In any scene with moving objects or dynamic materials, you will notice how the GI updates in real-time, which could be crucial for gameplay and visual storytelling.
Step 14: GI Controls
Max Bounces controls the bounces of the rays used to calculate GI. Increasing this value further brightens up the shadows and improves the accuracy of their shading. As with most of the ray-tracing settings, I don’t recommend increasing this value further unless you are rendering a static image.
Step 15: Ray-Traced Translucency
Two options are available for translucency type in the Details panel, Raster, and Ray-Traced. Enabling ray-traced translucency makes the glass sphere in my level look properly refractive.
Step 16: Translucency Controls
The shadow settings for translucency resemble the reflection shadows controls. Two different types of shadows are available, or alternatively, they can be completely disabled. In this scene, the shadows are mostly cast by the statue’s hands holding the spheres.
Step 17: Shader Complexity
Having the same type of shader can improve performance when using ray-tracing. You can visualize the shading types through the Ray-Tracing Debug options in the View Mode dropdown in the Viewport. In this case the sphere on the right is using a translucent shader and the fern in the center a masked shader, which appear red and violet respectively, contrasting with the green of the default shader.
Step 18: World Position Offset and Foliage
World Position Offset is currently not supported by ray-tracing. This material feature is used in most foliage shaders that use it to emulate the wind movement, and activating ray-tracing will make the affected meshes render incorrectly.
Step 19: Volumetric Fog
Another feature that unfortunately is not yet supported by ray-tracing is volumetric fog. In my environment, I use the fog to enhance the shininess of the golden artifact, and as you can see the yellow glow is completely absent from the reflection in the water.
Step 20: Ray-Tracing Quality Switch in the Materials
To simplify calculations and optimize your scenes further, a new node has been introduced in the Material Editor that allows you to indicate an alternative input for each material parameter to be used with ray-tracing. This node can be very useful for example to simplify materials with panning textures or to set a specific roughness value.
Step 21: Geo Complexity Affecting Ray-Tracing Calculations
Having a lot of highly detailed geometry in your scene can greatly affect performance when using ray-tracing. Smooth and clean surfaces will make the casted rays bounce off uniformly and simplify calculations. In my scene, replacing the two statues (containing a lot of crevices) with a simpler mesh improved performance by almost a full-frame per second.
Step 22: Rendering with Ray-Tracing
When rendering an image sequence or a video through the Sequencer Editor, the first few frames might appear extremely noisy, this is because raytraced GI and reflections need a few frames to calculate, even when enabling Warm-Up frames in the Animation settings. Keep this in mind when setting up renders with key-framed elements.
Step 23: The impact of Ray-Tracing
When positioning the cameras around my level, I came across this great example of how much ray-tracing can improve the visual read of the environment. Of course, there are many ways to improve the Global Illumination without enabling ray-tracing, but remember that ray-traced GI is dynamic, so changing the color of the terrain would update the indirect lighting immediately without having to rebake the lightmaps.
Step 24: Path-Tracing
The new Unreal update also includes an experimental Path-Tracer. This tool casts a much higher amount of rays in the scene and uses them to calculate every aspect of the meshes, from the base color to normals, working essentially like a traditional rendering engine like V-Ray.
Path-Tracing can be accessed in the View Mode dropdown menu in the Viewport and as you can see it renders a decently defined image that can be used as a comparison for how the scene would look like in a traditional renderer.
Top Tip 1: Generated LODs
I highly recommend having different LOD (level of detail) meshes for each of your assets. Fortunately you can generate them directly in the Engine from the Details panel in the Static Mesh Editor.
Top Tip 2: Color Grading
To improve the quality of your renders a wide array of tools are available in the Post Process Volume. I recommend starting from the Global Color Grading settings inside the Details panel of the Volume and always having a reference at hand to match.
Top Tip 3: Show FPS
A crucial tool to keep you in control of the performance in your scene is the FPS counter. Press Ctrl+Shift+H in the viewport and you will now have a constant indication on how the level will perform once you build the project, press the shortcut again to hide the counter.
Top Tip 4: View Modes and Buffer Visualization
In the Viewport you have access to a wide array of View Modes, the ones I use the most are Roughness and Ambient Occlusion, found inside the Buffer Visualization category.
Conclusion
I hope you found this article interesting and start testing out ray-tracing in your projects, you can find me active on these socials for any questions and feedback: Artstation, LinkedIn, and if you are interested in purchasing the assets I used to build this scene you can buy them on Gumroad.
Michelangelo Cellini, Associate Environment Texture Artist at Naughty Dog
Save yourself endless time and technical hurdles in the material editor, with my pack of Prop Master Materials for UE4!