Search Unity

High Definition Render Pipeline real-time ray tracing is now in Preview

, marzo 6, 2020

Along with package 7.2.0 of the High Definition Render Pipeline (HDRP), we’re delivering a preview version of real-time ray tracing. 

HDRP is used for creating high-definition and photorealistic visuals. The render pipeline is out of Preview starting with package version 7.2.0 in 2019.3 and Unity version 2019.3.2f1 (required for real-time ray tracing). You can find more details about HDRP here, but this blog post will focus specifically on the ray tracing features that HDRP offers.

HDRP follows physically based rendering rules, but it has limitations in its lighting processing due to the nature of the rasterization pipeline. Real-time ray tracing allows you to unlock greater visual fidelity since it doesn’t have the same visibility issues related to screen space approximation use in HDRP. It also allows you to avoid relying on pre-baking steps for lighting, which improves artists’ workflows.

There are two different uses of ray tracing in HDRP:

  1. A mix of real-time ray tracing techniques and rasterization, which we call the hybrid pipeline
  2. A progressive path tracer

The hybrid pipeline

The hybrid pipeline targets real-time applications. It relies on standard rasterization techniques – specifically, the HDRP pipeline – but it allows you to replace various effects with a ray-traced version. This increases the final image quality since ray tracing doesn’t suffer from the screen space approximation issues or other hard-to-solve problems that accompany the rasterization approach. 

The effects that support ray tracing have a corresponding ray tracing effects setting in HDRP. It is controlled either with a ray tracing flag on an existing effect or a new volume setting dedicated to it. The following section outlines the ray tracing effects available in HDRP. These effects are compatible with Lit.shader, Unlit.shader, and LayeredLit.shader, as well as the Shader Graph versions of Unlit, Lit and Fabric.

Ray Traced Reflections

HDRP offers several options for reflections: Screen Space Reflection, Reflection Probe, Planar reflection, and Sky reflection. Ray Traced Reflection adds a new choice to this list with higher visual fidelity. It’s accessible through the Screen Space Reflection volume component.

Ray Traced Global Illumination

The lightmapper in Unity allows you to produce either lightmaps or light probes to store the indirect diffuse lighting that the scene creates on an object. While the result this produces is visually compelling, it requires a baking step and can only be used to create static lighting. Ray Traced Global Illumination offers a new option, used with the Global Illumination volume component, to replace the baked lighting.

Ray-Traced Ambient Occlusion

Screen Space Ambient Occlusion (SSAO) is a great trick to simulate the complexity of indirect lighting in a scene. SSAO gives strong results, but it relies entirely on the data available onscreen, so it can have visible limitations that can be improved by its ray tracing variant: Ray Traced Ambient Occlusion. This feature is available through the Ambient Occlusion volume component.

Ray Traced Shadows

Ray Traced Shadows can replace regular shadows in HDRP. This setup has a few advantages: in addition to avoiding any issues related to shadow map resolution and bias, Ray Traced Shadows allow you to control the shadow penumbra (Point, Spot and Directional), and they support colored (Directional) or semi-transparent shadows (Point and Spot). View-dependent shadows for rectangular light are also supported. These options are available on the lights themselves.

Ray Traced Contact Shadows

Sometimes shadow maps have trouble capturing details, such as the contact between an object and its occluder due to low-resolution render targets or various bias issues. HDRP offers an option to improve this situation without increasing the shadow map resolution, called Contact Shadows. Contact Shadows rely on ray marching of the depth buffer, which can cause some screen space artifacts to display. Using Ray Traced Contact Shadows instead avoids the appearance of these artifacts. This option is available on the lights themselves.

Recursive Rendering

Rendering multiple layers of refractive transparent materials can be a tricky thing to do with the rasterization pipeline. HDRP only offers the option of a single refractive interface, and ray tracing offers an accurate way to do it. The Recursive Rendering volume component allows you to perform multiple reflections and refractions for transparent objects. It requires that the object’s material uses the ray-tracing setting in Rendering Pass.

Ray Traced Subsurface Scattering

Translucent surface rendering is a very complex problem that has only partially been solved in HDRP. The volume component Subsurface Scattering allows you to enable ray tracing to simulate this effect.

Performance

Real-time ray tracing is very intensive in GPU usage. Each ray has a cost that needs to be considered in the final frame rate of the application. With the current state of hardware, enabling all of these ray tracing effects at the same time will result in a slow frame rate. We recommend choosing which effects to enable with care. For games in particular, it’s advisable to enable only one or two effects at a time to avoid excessively high frame time. 

For many ray tracing effects, HDRP offers two modes: Quality and Performance.

There are additional options available depending on the chosen mode. Quality usually allows multiple bounce options for lighting effects (such as Reflection or Global Illumination) and uses less approximation in the shading model, which can increase graphic fidelity but is more GPU-intensive. For these reasons, this setting is not recommended for games. Performance is the mode to use when targeting game frame rate, applying complex optimizations under the hood.  You can learn more about the details of optimization performance in the talk “Leveraging Real-time Ray Tracing To Build A Hybrid Game Engine,” presented at SIGGRAPH 2019. Some effects don’t offer choices in mode settings because they only support Quality mode, such as the Recursive Rendering effect.

Ray Traced Global Illumination and Recursive Rendering aren’t recommended for a high frame rate target because they are quite expensive. It is useful to generate reference screenshots. You should also use the Ray Trace Subsurface Scattering feature economically, as its cost can increase quickly.

For games, it is recommended to restrict ray traced effects to Shadow, Contact Shadow, Ambient Occlusion, and reflections in Performance mode. Other effects can be used for interactive non-game applications in Performance mode when they are available, while any effects without a Performance mode setting should be used sparingly to stay in real-time.

Another option to help with performance is reducing the amount of work that occurs while performing ray tracing effects. The Shader Graph comes with a dedicated node for ray tracing that allows you to lower the cost of a material when it is rendered with ray tracing.

The progressive path tracer

The progressive path tracer pipeline targets high-quality image rendering, often for interactive applications. Unlike the hybrid pipeline, it doesn’t rely on the rasterization pipeline for shading, but it still does for post-processing. Lighting in this mode is very accurate, similar to what can be achieved in the movie industry, but it requires some time to be processed. As such, this method generates a noisy image for a few frames until the image converges to its final result.

A Path Tracing volume component is available and replaces any other ray tracing or regular pipeline effect in the HDRP when enabled. This can also be useful to produce a reference comparison.

Progressive rendering of the frame with Path tracer

Final result after full convergence of the image

What does it mean to be in Preview?

Ray tracing in HDRP 7.2.0 is in Preview. It relies on DX12 and DXR low-level APIs that are both in Preview in Unity 2019.3.2f1 and are thus missing some functionality. Ray tracing in Preview means that some functionalities, user interfaces, performance, tools, and data formats could evolve with new versions, and data migration isn’t guaranteed. It is not recommended to use Preview features in production.

HDRP ray tracing in Unity 2019.3 has the following limitations:

  • There is no support for ray tracing on platforms other than DX12, where only D3D12_RAYTRACING_TIER 1.0 is supported.
  • It does not support deformers (skin, vertex animation).
  • It does not support VFX and Terrain.
  • It does not support several of HDRP’s materials, includingHair, StackLit, Eye, and AxF materials.
  • It does not have correct culling for shadows. It uses frustum culling instead.

Hardware requirements

Full ray tracing hardware acceleration is available on following GPUs:

  • NVIDIA GeForce RTX 2060, RTX 2080 Super, RTX 2070, RTX 2070 Super, RTX 2080, RTX 2080 Super, RTX 2080 Ti
  • NVIDIA TITAN RTX
  • NVIDIA Quadro RTX 3000 (laptop only), RTX 4000, RTX 5000, RTX 6000, RTX 8000

NVIDIA also provides a ray tracing fallback for some previous generation graphics cards:

  • NVIDIA GeForce GTX
    • Turing generation: GTX 1650, GTX 1660 Super, GTX 1660 Ti
    • Pascal generation: GTX 1060, GTX 1070, GTX 1080, GTX 1080 Ti
  • NVIDIA TITAN V
  • NVIDIA Quadro: P4000, P5000, P6000, V100

If your computer has one of these graphics cards, it can run ray tracing in Unity. Before you open Unity, make sure to update your NVIDIA drivers to the latest version. Use NVIDIA Quadro or Studio Drivers for the optimal creation experience, and make sure that your Windows version is at least 1809.

Finding your way in HDRP ray tracing

To get started with HDRP ray tracing, check out the introductory documentation. It includes a detailed explanation of all of the ray tracing effects that were mentioned in this post. 

The best and simplest way to get started with ray tracing in HDRP is to explore the sample project provided, called SmallOfficeRayTracing. It is already set up for ray tracing, with effects enabled and configured properly, and it’s available here.

In the sample project, three scenes are available, and they exhibit three different use cases of real-time ray tracing.

Ray Tracing Performance Scene

This scene is set up to have several ray-tracing effects enabled with good performance in mind (~60 fps on an Nvidia 2080). The following effects are enabled:

  • Ray Traced Reflections
  • Ray Traced Global Illumination
  • Ray Traced Directional Shadow
  • Ray Traced Area Light Stochastic Shadow
  • Ray Traced Ambient Occlusion

Ray Tracing Quality Scene

This scene contains the same effects as the Performance scene with one additional effect, Recursive Rendering. These effects are configured with Quality mode (when this mode is available), and this increases the number of bounce for reflection.

Ray Tracing Path Tracing Scene

This scene is set up to be rendered using the progressive path tracer.

Starting a new project

To help you on your journey when starting a new project from scratch and ensure that you have the right setup for your ray tracing, we offer an HDRP Wizard. The Wizard validates your settings in the HDRP + DXR tab and can fix them if they are incorrect.

Otherwise, to manually set up ray tracing projects, please refer to Unity’s documentation

What’s Next?

Future development for real-time ray tracing includes more support for 

  • HDRP materials (StackLit, Hair, etc.)
  • Geometry (Terrain, Particles, etc.)
  • Virtual Reality
  • Better fallback to get improved scalability between configurations 

In Unity 2020.1, skinning, blend shape, and alembic deformation are supported.

Start using HDRP ray tracing

You can start taking advantage of HDRP ray tracing in your projects today – but remember, this feature is not yet production-ready. You can also refer to presentations by the Unity team at events such as Unite, SIGGRAPH or GDC and our blog posts Reality vs lllusion and Ray Tracing – What does it mean for you? There is a starter presentation from SIGGRAPH, and if you want to go deeper and learn more about the architecture of HDRP ray tracing, you can watch the talk Leveraging Ray Tracing Hardware Acceleration In The Unity Game Engine.

Our team is just getting started, and development continues. Please share any feedback about your experience in the HDRP RayTracing forum!

7 replies on “High Definition Render Pipeline real-time ray tracing is now in Preview”

Great post. Personally I was wishing that Unity would wait for a while for Raytracing as a technology to mature enough and be widely adopted across multiple hardware and graphics libraries before Unity jumps on board. But I get that it’s got to compete with Unreal so sometimes, vanity features like this are a necessary evil. Nonetheless the results are pretty stunning.

Sadly, vanity features such as these are often the differentiator about what engine to use even when it makes no sense whatsoever. Your artists demand it, your designers demand it, sometimes even your investors demand it. So it is important not only to be current, but also be the one on top of the vanity feature list.

Thanks. That would be great news… Last year. In the mean time competitors using other engines are providing more advanced visualization solutions today. Please enable Raytrace in VR for 2020.1 and what would be great news today, would be that you are working on URP support too. I look forward to it!

Normally yes. That is one of the huge benefits Quadro cards had since their invention. If I am not mistaken, at least up to 4 Quadros can be used simultaneously. Whether DXR takes advantage of that or how you should structure your project in order to take advantage of them is a different matter.

I know Unity is vey big on multi-platform support. Are you planning on adding ray-tracing support to other platforms? (Metal, Vulcan, etc.)

Comments are closed.