Reflections and real-time effects for PC and console games

This is the fourth in a series of articles that explains how developers and technical artists can set up and use the High Definition Render Pipeline (HDRP) in Unity to achieve high-end graphical realism. HDRP represents a technological leap in Unity’s real-time rendering so you can work with light just as it behaves in the real world.

Be sure to read the other articles in our how-to series for high-end lighting:

Demonstração de Reflection Probes

Os Volumes de Influência determinam onde as Reflection Probes criam reflexões.

Reflections

Reflections help integrate GameObjects with their surrounding environment. While we normally associate reflections with smooth and shiny surfaces, even rough materials require correct reflections in a physically based rendering (PBR) workflow. HDRP offers multiple techniques to generate reflections:

  • Screen Space Reflections
  • Reflection Probes
  • Sky Reflections

Each reflection type can be resource-intensive, so carefully select the method that works best depending on your use case. If more than one reflection technique applies to a pixel, HDRP blends the contribution of each reflection type. Bounding surfaces called Influence Volumes partition the 3D space to determine what objects receive the reflections.

Interface de Screen Space Reflection Override

Screen Space Reflection Override

Screen Space Reflections

Screen Space Reflections (SSR) use the depth and color buffer to calculate reflections. As such, they can only reflect objects currently in Camera view and might not render properly at certain positions onscreen. Glossy floorings and wet planar surfaces are good candidates for receiving Screen Space Reflections, but note that SSRs ignore all objects outside of the frame, which can limit the effect.

To enable Screen Space Reflections, go to Frame Settings (HDRP Default Settings or the Camera’s Custom Frame Settings) under Lighting. Then, add the Screen Space Reflection Override to your Volume Object.

Material surfaces must exceed the Minimum Smoothness value to show Screen Space Reflections. Lower this value if you want rougher materials to show the SSR, but be aware that a lower Minimum Smoothness threshold can add to the computation cost. If Screen Space Reflection fails to affect a pixel, then HDRP falls back to using Reflection Probes.

Use the Quality drop-down to select a preset number of Max Ray Steps. Higher Max Ray Steps increase quality but also come with a cost. As with all effects, strive to balance performance with visual quality.

In HDRP versions 12 and above, you can choose between a physically based algorithm using Accumulation (new) or Approximation, a less accurate approximate algorithm (default).

Componente da Reflection Probe

Componente da Reflection Probe

Reflection Probes

Reflection Probes generate reflections using an image-based technique. A probe captures the spherical view of its surroundings in all directions and stores the result in a cubemap texture. Shaders use this cubemap to approximate a reflection.

Each scene can have several probes and blend the results. Localized reflections can then change as your Camera moves through the environment.

Set the Type of each Reflection Probe to Baked or Real-time:

  • Baked Probes process the cubemap texture just once for a static environment.
  • Real-time Probes create the cubemap at runtime in the Player rather than in the Editor. This means that reflections are not limited to static objects, though real-time updates can be resource-intensive.

The Influence Volume determines the 3D boundaries where GameObjects will receive the reflection, while the Capture Settings let you customize how the Reflection Probe takes a snapshot of the cubemap.

To optimize real-time reflection probes, disable any rendering feature which is not significantly affecting the visual quality of reflections by overriding general or per reflection probe camera settings. You can also create a script to time slice the update.

Diagrama de Planar reflection probe

Uma Planar Reflection Probe captura uma imagem espelhada refletindo a Câmera através de um plano.

Planar Reflection Probe

A Planar Reflection Probe allows you to recreate a flat, reflective surface, taking surface smoothness into account. This is ideal for shiny mirrors and floors.

Though Planar Reflection Probes share much in common with standard Reflection Probes, these components work slightly differently. Rather than capture the environment as a cubemap, a Planar Reflection Probe recreates the Camera view reflected through its mirror plane. The probe then stores the resulting mirror image in a 2D RenderTexture. Drawn to the boundaries of the rectangular probe, this creates a planar reflection.

If an object is not affected by a nearby Reflection Probe, it will fall back to the Sky Reflection.

Demonstração de vazamento de luz

A desativação da Reflection Probe no teto da Sala 3 causa vazamento de luz indesejado.

Reflection Hierarchy

To produce top-quality reflections, HDRP uses the technique that provides the most accuracy for each pixel, and combines it with other techniques based on the three reflection methods (SSR, Reflection Probes, Sky) using a weighted priority. This specific sequence for evaluating reflections is called the Reflection Hierarchy.

When one technique does not fully determine the reflection of a pixel, HDRP falls back to the next technique. In other words, Screen Space Reflection falls back to the Reflection Probes, which in turn, fall back to Sky Reflections.

It’s important to set up Influence Volumes for your Reflection Probes properly. Otherwise, you might experience light leaking from unwanted Sky Reflections. This is apparent in Room 3 of the Sample Scene. Disabling one of the Reflection Probes or shifting its Influence Volumes forces the reflection to fall back to the Sky. This causes the bright HDRI Sky to overpower the scene with its intense reflections.

For more details on Reflection Hierarchy, see the Reflection section of the HDRP documentation.

Reflection proxy volume

Um Reflection Proxy Volume reprojeta o mapa do cubo para corresponder à posição do espaço do mundo da sala.

Reflection Proxy Volumes

Because the capture point of a Reflection Probe is fixed and rarely matches the Camera position nearby, there can be a noticeable perspective shift in the resulting reflection. As such, the reflection might not look connected to the environment.

A Reflection Proxy Volume helps you partially correct this. It reprojects the reflections more accurately within the Proxy Volume, based on the Camera position.

Interface de Ambient Occlusion Override

Ambient Occlusion Override

Real-time lighting effects

HDRP also features some real-time lighting effects available via the Volume system. Select a Local or Global Volume, then add the appropriate effect under Add Override > Lighting.

Screen Space Ambient Occlusion (SSAO)

Ambient Occlusion simulates darkening that occurs in creases, holes, and surfaces that are close to one another. Areas that block out ambient light tend to appear occluded.

Although you can bake Ambient Occlusion for static geometry through Unity’s Lightmapper, HDRP adds an additional Screen Space Ambient Occlusion, which works in real-time. This is a screen space effect, meaning that only information from within the frame can contribute to the effect produced. SSAO ignores all objects outside of the Camera’s field of view.

Enable Screen Space Ambient Occlusion in the Frame Settings under Lighting. Then, Add Override on a Local or Global Volume and select Lighting > Ambient Occlusion.

Demonstração de iluminação global do espaço da tela na folhagem

A Iluminação global do Screen Space captura a luz refletida da folhagem em tempo real.

Screen Space Global Illumination

Screen Space Global Illumination (SSGI) uses the Depth and Color buffer of the screen to calculate bounced, diffuse light. Much like how lightmapping can bake indirect lighting into the surfaces of your static level geometry, SSGI more accurately simulates how photons can strike surfaces and transfer color and shading as they bounce.

Like other effects that depend on the Frame buffer, the edges of the screen become problematic, since objects outside the Camera’s field of view cannot contribute to Global Illumination. This can be partially improved by using reflection probes to provide a fallback when ray marching outside of the Frame buffer.

Enable SSGI in the Frame Settings under Lighting. It must be enabled in the Pipeline Asset’s Lighting section as well.

Note: We recommend using Unity 2021.2 or above with Screen Space Global Illumination. HDRP 12 includes significant improvements to SSGI quality.

Interface de refração

Entradas de transparência para controlar a refração

Screen Space Refraction

The Screen Space Refraction Override helps simulate how light behaves when passing through mediums denser than air. HDRP’s Screen Space Refraction uses the Depth and Color buffer to calculate refraction through a transparent material like glass.

To enable this effect through the HDRP Lit Shader, make sure your material has a Surface Type that is Transparent.

Then choose a Refraction Model and Index of Refraction under Transparency Inputs. Use the Sphere Refraction Model for solid objects, and choose Thin (like a bubble) or Box (with some slight thickness) for hollow objects.

Was this content helpful?

Usamos cookies para garantir a melhor experiência no nosso site. Visite nossa página da política de cookies para obter mais informações.

Eu entendi