Use the screen space reflection (SSR) override
The Screen Space Reflection (SSR) override is a High Definition Render Pipeline (HDRP) feature that uses the depth and color buffer of the screen to calculate reflections. For information about how SSR works in HDRP, see Understand reflection in HDRP.
HDRP implements ray-traced reflection on top of this override. This means that the properties visible in the Inspector change depending on whether or not you enable ray tracing.
Enable screen space reflection
To use this feature in your Scene, you must first enable it for your project and then enable it for your Cameras. To enable features in your project, you use the HDRP Asset and to enable features for your Cameras, you use Frame Settings. You can enable features either for all Cameras, using the Default Frame Settings, or for specific Cameras, by overriding each Camera's individual Frame Settings.
To enable SSR:
- Open your HDRP Asset in the Inspector.
- Go to Lighting > Reflections and enable Screen Space Reflection.
- Go to Edit > Project Settings > Graphics > Pipeline Specific Settings > HDRP > Frame Settings (Default Values) > Lighting and enable Screen Space Reflection.
Set up screen space reflection
HDRP uses the Volume framework to calculate SSR, so to enable and modify SSR properties, you must add a Screen Space Reflection override to a Volume in your Scene. To add Screen Space Reflection to a Volume:
- In the Scene or Hierarchy view, select a GameObject that contains a Volume component to view it in the Inspector.
- In the Inspector, navigate to Add Override > Lighting and click Screen Space Reflection. HDRP now calculates SSR for any Camera this Volume affects.
API
To access and control this override at runtime, use the Volume scripting API. Because of how the Volume system works, you edit properties in a different way to standard Unity components. There are also other nuances to be aware of too, such as each property has an overrideState. This indicates to the Volume system whether to use the property value you set, or use the default value stored in the Volume Profile. For information on how to use the API correctly, see Volume scripting API.
Tracing modes
The properties visible in the Inspector change depending on the option you select from the Tracing drop-down:
- To use a screen-space, ray-marched solution, select Ray Marching and see Screen-space for the list of properties.
- To use ray tracing, select Ray Tracing and see Ray-traced for the list of properties.
- To use a combination of ray tracing and ray marching, select Mixed and see Ray-traced for the list of properties. For more information about mixed tracing mode, see mixed tracing
Mixed tracing
This option uses ray marching to intersect on-screen geometry and uses ray tracing to intersect off-screen geometry. This enables HDRP to include on-screen opaque particles, vertex animations, and decals when it processes the effect. This option only works in Performance mode and with Lit Shader Mode setup to Deferred.
In Mixed tracing mode, HDRP processes screen-space ray marching in the GBuffer. This means that it can only use GameObjects rendered using the deferred rendering path. For example, HDRP renders transparent GameObjects in the forward rendering path which means they don't appear in the GBuffer or in effects that use mixed tracing.
In Mixed tracing mode, HDRP still uses ray tracing for any geometry inside the ray tracing acceleration structure, regardless of whether vertex animation or decals modify the geometry's surface. This means if HDRP fails to intersect the on-screen deformed geometry, it intersects the original mesh inside in the ray tracing acceleration structure. This may cause visual discrepancies between what you see and what you expect. For example, the following Scene contains a cliff that uses mesh deformation.
In this Scene, Mixed mode can include reflections for the opaque leaf particles, the white decal, and GameObjects that aren't visible in the cliff face's non-deformed geometry.
Reflection rays intersect with the original, non-deformed cliff face geometry. This means the rays can still be affected by the bush behind the rock. To view the Scene from the perspective of the ray tracing mode, refer to the following image.
This image shows the elements of the Scene that ray tracing takes into account. The non-deformed cliff face geometry reveals the bushes behind the rocks.
Tracing Modes Limitation
Ray Marching
- Transparent Emissive Material are only taken into account when you set Rendering Pass to Before Refraction.
Ray Tracing
- Transparent Emissive Material aren't taken into account.
- No decals are supported including Emissive Decals.
Mixed Tracing
- The Mixed tracing mode is only useful if you set the Lit shader mode to Deferred and have the same limitation than Ray Tracing mode.
To learn about the Screen Space Reflection override properties, refer to Screen space reflection (SSR) reference.
Debug screen space reflection speed rejection
HDRP includes a Fullscreen Debug Mode called Screen Space Reflection Speed Rejection (menu: Lighting > Fullscreen debug mode > Screen Space Reflection Speed Rejection) that you can use to visualise the contribution of the following properties:
- Speed Rejection
- Speed Rejection Scaler Factor
- Speed From Reflecting Surface
- Speed From Reflected Surface
- Speed Smooth Rejection
This fullscreen debug mode uses a color scale from green to red. Green areas indicate the sample is accumulated according to the Accumulation Factor and red areas indicate that HDRP rejects this sample. Orange areas indicate a that HDRP accumulates some samples and rejects some samples in this area.
In the following example image, the car GameObject is in the center of the Camera's view. This means the car has no relative motion to the Camera.
This example image uses Speed From Reflected Surface to accumulate the samples from the car and partially accumulate the samples from the sky. This makes the car and its reflection appear green, and the surface that reflects the sky appear orange.
Limitations
Screen-space reflection
To calculate SSR, HDRP reads a color buffer with a blurred mipmap generated during the previous frame.
The color buffer only includes transparent GameObjects that use the BeforeRefraction Rendering Pass. However, HDRP incorrectly reflects a transparent GameObject using the depth of the surface behind it, even if you enable Depth Write in the GameObject's Material properties. This is because HDRP calculates SSR before it adds the depth of transparent GameObjects to the depth buffer.
If a transparent material has Receive SSR Transparent enabled, HDRP always uses the Approximation algorithm to calculate SSR, even you select PBR Accumulation.
When a transparent material has rendering pass set to Low Resolution, then Receive SSR Transparent can't be selected.
Ray-traced reflection
Currently, ray tracing in HDRP doesn't support decals. This means that, when you use ray-traced reflection, decals don't appear in reflective surfaces.
If a transparent material has Receive SSR Transparent enabled, HDRP will evaluate the reflections as smooth.