How to use HDRIs in Unity?

How to use HDRIs in Unity?

High Dynamic Range Imaging (HDRI) is a technique that captures a wider range of light and colour values than traditional image formats. This technique is commonly used in 3D graphics to create more realistic lighting environments. In this tutorial, we will explore how to use HDRI in Unity to create immersive and realistic lighting environments for your projects.

Step 1: Downloading HDRI Images

The first step in using HDRI in Unity is to find and download suitable HDRI images. You can find HDRI images for your requirements from our library or from other online sources. You can also create your own HDRI images using a camera and software such as Adobe Photoshop or PTGui.

When choosing an HDRI image, it is important to consider the lighting conditions that you want to simulate. For example, if you want to create an outdoor environment, you might want to choose an HDRI image that captures a sunny day with clear blue skies. On the other hand, if you want to create an indoor environment, you might want to choose an HDRI image that captures a room with soft, diffused lighting.

Step 2: Importing HDRI Images into Unity

Once you have downloaded or created your HDRI images, the next step is to import them into Unity. To do this, follow these steps:

  1. Open your Unity project and navigate to the “Assets” folder.
  2. Create a new folder called “HDRI” (or any name of your choice) inside the “Assets” folder.
  3. Drag and drop the HDRI image files into the “HDRI” folder.

Unity HDRI Setup

Step 3: Creating a Skybox

The next step is to create a Skybox using the HDRI image. A Skybox is a 6-sided cube that surrounds the entire scene, providing the illusion of a background and adding depth to the environment. To create a Skybox using an HDRI image, follow these steps:

  1. In the Unity Editor, go to “Window” > “Rendering” > “Lighting”.
  2. In the “Lighting” window, go to the “Scene” tab.
  3. Click on the “Environment” header to expand the settings.
  4. Click on the small circle next to the “Skybox Material” field to create a new Skybox material.
  5. In the “Create Material” window, give the material a name (e.g. “Skybox Material”) and select “Skybox” as the shader type.
  6. Drag and drop the HDRI image file onto the “Skybox Material” in the “Inspector” window.
  7. Go back to the “Environment” settings and select the new “Skybox Material” from the “Skybox Material” field.

Step 4: Adjusting Skybox Settings

After creating the Skybox, you can adjust various settings to fine-tune the environment’s lighting. To do this, follow these steps:

  1. In the “Lighting” window, go to the “Scene” tab.
  2. Click on the “Environment” header to expand the settings.
  3. Adjust the “Exposure” setting to control the overall brightness of the scene.
  4. Adjust the “Rotation” setting to change the orientation of the HDRI image.
  5. Adjust the “Intensity” setting to control the strength of the HDRI image’s lighting.
  6. Adjust the “Ambient Lighting” setting to control the overall color tone of the scene.

HDRi lighting settings in Unity

Step 5: Adding Reflection Probes

Reflection Probes are another important element in creating a realistic environment with HDRI lighting. They capture the surrounding environment’s lighting information and use it to reflect light onto objects in the scene. To add a Reflection Probe, follow these steps:

  1. In the Unity Editor, select the object in the scene that you want to add the Reflection Probe to.
  2. Go to “Component” > “Rendering” > “Reflection Probe”.
  3. In the “Reflection Probe” component, adjust the “Type” setting to determine the type of Reflection Probe you want to use. The options are “Box”, “Sphere”, and “Custom”.
  4. Adjust the “Resolution” setting to determine the quality of the Reflection Probe’s reflection.
  5. Position and scale the Reflection Probe in the scene as needed.

It is important to note that adding too many Reflection Probes can have a negative impact on performance, so use them judiciously.

Step 6: Using HDRI Lighting for Objects

Now that you have set up the HDRI lighting environment and added Reflection Probes, you can use it to light objects in your scene. To do this, follow these steps:

  1. Select the object you want to add HDRI lighting to.
  2. Go to “Component” > “Rendering” > “Mesh Renderer”.
  3. In the “Mesh Renderer” component, check the “Use Light Probes” and “Reflection Probes” checkboxes.
  4. Adjust the “Light Probe Usage” setting to determine how the object should be lit by Light Probes.
  5. Adjust the “Reflection Probe Usage” setting to determine how the object should reflect light from Reflection Probes.

By using HDRI lighting and Reflection Probes, you can create realistic and immersive environments in your Unity projects.

Conclusion

In this tutorial, we have explored how to use HDRI in Unity to create realistic lighting environments. By downloading or creating HDRI images, importing them into Unity, creating a Skybox, adjusting Skybox settings, adding Reflection Probes, and using HDRI lighting for objects, you can create stunning environments that will enhance the overall look and feel of your Unity projects.