Get started with lighting in Unity for PC and console games
This is the first 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:
HDRP extends Unity’s existing lighting system with a variety of features to make rendering your scene more closely resemble real-world lighting:
- Physical light units and exposure: HDRP uses real-world lighting intensities and units. Match the specs from known light sources and set exposures using physical cameras.
- Advanced lighting: Take control over light placement with additional shape options for spot and area lights. Use Light Layers to limit the influence of lights onto specific meshes. Apply real-time effects like Screen Space Global Illumination (SSGI) and Screen Space Refraction.
- Skyscapes: Generate natural-looking skies with varied techniques. Use the Physically Based Sky system to simulate planetary atmosphere procedurally, and add Volumetric Clouds, Cloud Layers, or apply HDRIs to simulate static skies.
- Fog: Add depth and dimension to your scenes with fog. Enable volumetrics to integrate fog effects with your foreground objects and render cinematic shafts of light. Maintain per-light control of volumetric light and shadows and use the Local Volumetric Fog component for fine control of fog density with a 3D mask texture.
- Volume system: HDRP features an intuitive system that lets you block out different lighting effects and settings based on Camera location or by priority. Layer and blend Volumes to allow expert-level control over every square meter of your scene.
- Post-processing: HDRP post-processing is controlled by a series of Volume Overrides on top of the existing Volume system. Add anti-aliasing, tonemapping, color grading, bloom, depth of field, and a host of other effects.
- Advanced shadows: HDRP offers advanced artistic and performance control over shadows. Modify their tint, filtering, resolution, memory budget, and update modes. Accentuate small details and add depth with Contact Shadows and Micro Shadows.
- Advanced reflections: Reflective surfaces can use several techniques to render. Reflection Probes offer a traditional reflection mapping approach, with Planar Reflection Probes giving you more advanced options for flat surfaces.Screen Space Reflection (SSR) adds a real-time technique using the Depth buffer.
Unity 2021 LTS and above includes the HDRP package with installation to ensure that you’re always running on the latest verified graphics code. When you install the most recent Unity release, it also installs the corresponding version of HDRP.
HDRP package version Compatible Unity version 13.x 2022.1 12.x 2021 LTS (used in this guide)
Tying the HDRP graphics packages to specific Unity releases helps maintain compatibility. However, you can also switch to a custom version of HDRP by overriding the manifest file.
System requirements
HRDP is currently compatible with the following target platforms:
- Windows and Windows Store, with DirectX 11 or DirectX 12 and Shader Model 5.0
- Modern consoles (minimum Sony PlayStation 4 or Microsoft Xbox One)
- MacOS (minimum version 10.13) using Metal graphics
- Linux and Windows platforms with Vulkan
HDRP only works on console and desktop platforms that support compute shaders. It does not support OpenGL or OpenGL ES devices. Refer to the documentation for further details on requirements and compatibility.
See Virtual Reality in the High Definition Render Pipeline to learn about supported VR platforms and devices.
To set up an HDRP project, start in the Unity Hub:
First create a new project and select either the 3D (HDRP) empty template or 3D Sample Scene (HDRP) from the available templates listed (called High Definition RP in older versions of the Hub). To import the HDRP package with some example presets, choose the latest template.
If you create your project with the 3D Coretemplate, Unity uses the older Built-in Render Pipeline. You can migrate the project to HDRP manually from the Package Manager (Window > Rendering > HDRP Wizard).
Find the High Definition RP package in the Unity Registry, or use the Search field to locate and install it.
If there is a conflict with the current Project Settings, the HDRP Render Pipeline Wizard will appear to help you troubleshoot (also found under Window > Render Pipeline > HDRP Wizard). Note that in Unity 2021.2/HDRP 12, it is located under Window > Rendering > HDRP Wizard.
Go to Configuration Checking and click Fix All, or click Fix for each issue to repair them individually. This checklist can help you migrate from a non-Scriptable Render Pipeline (SRP) project.
When the Wizard finishes, a prompt will ask you to create a new Pipeline Asset. This is a file on disk that will hold your specific Pipeline Settings. Select Create One to add a new Render Pipeline Asset, and assign the file there.
Once HDRP is functioning properly, verify that all of the checkboxes in the Configuration Checking are green. You might notice the background environment change color.
Remember that manual installation from a blank project does not automatically import the 3D Sample Scene (HDRP). Use the 3D Sample Scene template if you want access to the example assets shown in this guide.
The 3D Sample Scene from the Unity Hub is a template project that helps you get started with HDRP and physically based lighting. This lightweight project is less than 100 megabytes, and it offers a good working example of HDRP that you can load quickly for reference.
The small, multi-room environment demonstrates three distinct areas with different lighting setups. The Directional light representing the sun has a real-world intensity of 100,000 lux, and each location corrects the Camera’s exposure to match the lighting environment.
Use the WASD keys and mouse to drive the FPS controller around the level.
- Room 1 is a round platform lit by the overhead sunlight. Decals add grime and puddles of water to the concrete floor.
- Room 2 adds volumetric shafts of light from the skylight, as well as advanced materials for the tree inside the glass case.
- Room 3 showcases interior artificial lighting and emissive materials.
For a closer look, check out this blog post from Unity Technical Artist Pierre Yves Donzallaz, which describes the HDRP 3D Sample Scene in greater detail.
More HDRP sample content
You might find some other projects helpful once you’re done exploring the HDRP 3D Sample Scene.
Though not originally intended for gaming, the Auto Showroom project demonstrates a highly detailed vehicle with realistic lighting. Change the stage lights, car paint, textures, and backdrop in this interactive demo available via the Unity Hub.
Meanwhile, the Spaceship demo showcases the Visual Effect Graph, among other HDRP features, in a sci-fi environment. You can download it from Unity’s GitHub repository or access it on Steam.
If you’re using HDRP with VR, you’ll appreciate the VR Alchemist Lab. This project presents interactive effects in a small medieval laboratory.
To learn how to create cinematic content or animated films, install our Cinematic Studiotemplate from the Unity Hub. This template illustrates how to set up and light the shots of a funny short film called Mich-L, blending stylized and photoreal rendering.
There are a few essential settings under Project Settings (Edit > Project Settings), including Graphics, HDRP Global Settings, and Quality.
Note that HDRP Default Settings is now called HDRP Global Settings in Unity 2021.2/HDRP 12 and above.
Graphics Settings
The Scriptable Render Pipeline Settings at the top of the image refers to a file on disk that stores all of your HDRP settings. You can have multiple such Pipeline Assets per project.
Think of each one as a separate configuration file. For example, you might use them to store specialized settings for different target platforms (Xbox, PlayStation, and so on), or they might also represent different visual quality levels that the player can swap at runtime.
The 3D Sample Scene begins with several Pipeline Assets in the Settings folder: HDRPHighQuality, HDRPLowQuality, and HDRPMediumQuality. There is also a HDRPDefaultResources folder containing a DefaultHDRPAsset.
The Quality Settings let you associate one of your Pipeline Assets to a predefined Quality Level.
Select a Quality Level at the top to activate a specific Render Pipeline Asset from the Rendering options. You can customize the defaults or create additional Quality Levels, each paired with additional Pipeline Assets.
A Quality Level represents a specific set of visual features active in the pipeline. For example, you can create several tiers for graphics within your application. At runtime, your players can then choose the active Quality Level, depending on your hardware.
Go to the Quality/HDRP subsection to edit the actual Pipeline Settings. Otherwise, go to Project view to select the Pipeline Asset and edit its settings in the Inspector.
Please be aware that enabling more features in the Pipeline Asset will consume more resources. In general, optimize your project to use only what you truly need to achieve the intended effect. If you don’t need a particular feature, you can turn it off to save resources and improve performance.
Here are some features that you can disable if you don’t need to use them:
- In the HDRP Asset: Decals, Low-res Transparency, Transparent Backface/Depth Prepass/Postpass, SSAO, SSR, Contact Shadows, Volumetrics, Subsurface Scattering, and Distortions
- In the Camera’s Frame Settings (Main Camera) used for integrated effects like reflections, or additional cameras used for custom effects: Refraction, Post-processing, After Post-processing, Transmission, Reflection Probe, Planar Reflection Probe, and Big Tile Prepass
Read this blog post to get acquainted with HDRP features for enhanced performance.
HDRP Global Settings
The HDRP Global Settings section, also known as the HDRP Default Settings (prior to HDRP version 12), determines the baseline configuration of your project. You can override these settings in the scene via Local or Global Volumecomponents, depending on Camera position.
Global Settings save in their own separate Pipeline Asset defined at the top field, where you can set up default rendering and post-processing options.
As you develop your project, you might need to return to the HDRP Global settings to toggle specific features on or off. Some features will not render unless their corresponding checkbox in Global Settings is enabled.
Make sure that you only enable the features you need, as they can have a negative impact on rendering performance and memory usage. Note that certain settings appear in the Volume Profiles, whereas other features are located in the Frame Settings (depending on usage).
While familiarizing yourself with HDRP’s feature set, make use of the top-right Search field in Project Settings. This will show only relevant panels with search terms highlighted.
Enabling a feature in the HDRP Global Settings does not guarantee it can be rendered by any camera, at any given time. You must verify that the Render Pipeline Asset, with its Quality Levelspecified under Projects Settings > Quality, supports that feature as well. For instance, to ensure cameras can render Volumetric Clouds, you must toggle them under HDRP Global Settings > Frame Settings > Camera > Lighting and in the active Render Pipeline Asset, under Lighting > Volumetrics.
If you are not CPU-bound, resolution can greatly impact performance. Dynamic resolution reduces the rendering resolution and scales the result to the output screen resolution. Filters performing this upscale have strongly improved in 2021 LTS, allowing you to render at 70% or lower resolution with minimal quality loss.
In Unity 2021 LTS, HDRP offers multiple solutions with some of the latest Super Sampling technologies:
- NVIDIA DLSS (Deep Learning Super Sampling) for GPUs that support it
- AMD FSR (FidelityX Super Resolution) across platforms
- TAA Upscale (Temporal Anti-Aliasing) across platforms
You can either force scaling in the HDRP Asset or code your own logic to adjust the scale.
To set up dynamic resolution in your project and get some guidance on choosing the best algorithm for your needs, see this page from the documentation.
When configuring HDRP Settings in the Pipeline Asset, you will typically start with the Lit Shader Mode under Rendering, where you can choose between Deferred, Forward, or Both. These represent rendering paths that you can select, each with a specific series of operations that inform how the pipeline will render and light the geometry. See how to customize your render path above.
To set your default rendering path, go to Lit Shader Mode and select Forward or Deferred. HDRP is flexible and also allows you to choose Both. This option lets you use one render path for most rendering, and then overrides it for each camera. However, it does take more GPU memory, so it is usually better to choose either Forward or Deferred.
To affect all cameras by default, go to HDRP Default Settings and locate Default Frame Settings. Your rendering path can be applied to Cameras, Baked or Custom Reflection, and Real-time Reflection. In the Rendering group, set the render path in the Lit Shader Mode.
To affect a specific camera, check its Custom Frame Settings. Then, in the Rendering group, override and change the rendering path of the Lit Shader Mode.
In Forward rendering, the graphics card splits the onscreen geometry into vertices. Those vertices are further broken down into fragments, or pixels, which render to screen and create the final image.
Each object passes, one at a time, to the graphics API. Forward rendering comes with a cost for each light. The more lights in your scene, the longer rendering will take.
Forward rendering draws lights in separate passes. If you have multiple lights hitting the same GameObject, this can create significant overdraw and slow things down when many lights and objects are present.
Unlike traditional Forward rendering, HDRP adds new capabilities, such as culling and rendering several lights together in a single pass per object material. But it’s still a relatively expensive process. If performance is an issue, you might want to use Deferred shading instead.
HDRP can also leverage Deferred shading, where lighting is not calculated per object. Instead, Deferred shading postpones heavy rendering to a later stage and uses two passes.
During the first pass, or the G-buffer geometry pass, Unity renders the GameObjects. This pass retrieves several types of geometric properties and stores them in a set of textures (e.g., diffuse and specular colors, surface smoothness, occlusion, normals, and so on).
In the second pass, or lighting pass, Unity renders the scene’s lighting after the G-buffer is complete, thus deferring shading. The Deferred shading path iterates over each pixel and calculates the lighting information based on the buffer as opposed to the individual objects.
For more information on the technical differences between rendering paths, see Forward and Deferred rendering in the HDRP documentation.