Recursive rendering
This feature is a replacement pipeline for rendering Meshes in the High Definition Render Pipeline (HDRP). GameObjects that use this rendering mode cast refraction and reflection rays recursively. This means that when a ray hits a surface, it reflects or refracts and carries on to hit other surfaces. You can control the maximum number of times that a ray does this to suit your Project.
The smoothness of a Material does not affect the way a ray reflects or refracts, which makes this rendering mode useful for rendering multi-layered transparent GameObjects.
Car gear shift rendered with recursive ray tracing
Using Recursive rendering
Recursive Rendering uses the Volume framework, so to enable this feature and modify its properties, you need to add a Recursive Rendering override to a Volume in your Scene. To do this:
- In the Scene or Hierarchy view, select a GameObject that contains a Volume component to view it in the Inspector.
- In the Inspector, go to Add Override > Ray Tracing and click on Recursive Rendering.
- In the Inspector for the Recursive Rendering Volume Override, check the Enable option. If you do not see the Enable option, make sure your HDRP Project supports ray tracing. For information on setting up ray tracing in HDRP, see getting started with ray tracing.
Now that you have recursive rendering set up in your Scene, you must set GameObjects to use the Raytracing rendering pass to make HDRP use recursive rendering for them. To do this:
- Select the GameObject in the Scene view or Hierarchy to view it in the Inspector.
- Select the Material attached to the GameObject.
- In the Surface Options foldout, enable Recursive Rendering (Preview).
You can also do this for Shader Graph master nodes:
- In the Project window, double-click on the Shader to open it in Shader Graph.
- In the Graph Settings tab of the Graph Inspector, go to Surface Options and enable Recursive Rendering (Preview).
It is best practice to use recursive rendering in situations that require multi-bounced reflection and refraction, for example car headlights. Although recursive rendering also produces ray-traced reflections in more simple scenarios, like for a mirror or a puddle, it is best practice to use ray-traced reflections here for performance reasons.
Since recursive rendering uses an independent render pass, HDRP cannot render any other ray-traced effects on recursively rendered GameObjects. For example, it cannot render effects such as ray-traced subsurface scattering or ray-traced shadows.
Properties
Property | Description |
---|---|
LayerMask | Defines the layers that HDRP processes this ray-traced effect for. |
Max Depth | Controls the maximum number of times a ray can reflect or refract before it stops and returns the final color. Increasing this value increases execution time exponentially. |
Ray Length | Controls the length of the rays that HDRP uses for ray tracing. If a ray doesn't find an intersection, then the ray returns the color of the sky. |
Min Smoothness | Defines the threshold at which reflection rays are not cast if the smoothness value of the target surface is inferior to the one defined by the parameter. |