Search Unity

Being part of the Spotlight Team, I am fortunate to be involved in some very interesting projects. The Spotlight Team at Unity works on games together with our customers and a significant part of my role is to help developers achieve the desired look and quality for their projects. I get to hear many stories from all across the industry and can identify common issues that content creators are facing. Several of the projects I have worked on aimed for fairly realistic visuals. Given the project’s art contents, how do we make a scene in Unity that will look believable?

There are a multitude of topics that need to be covered in order to make believable visuals. In this post I’m going to discuss lighting and render settings. Further down the post I’ll also share our Spotlight Tunnel Sample Scene and explain how you can use it to learn and experiment.

Preparing Unity render settings

Understanding how Unity’s rendering features can be used to realistically mimic the real world will help you to achieve your project’s visual goal.

Linear rendering mode
In simple terms, this sets Unity to do lighting and shading calculations using physically accurate math before transforming the final output into the format that works best for monitors.

To specify a gamma or linear workflow,
go to Edit > Project Settings > Player and open Player Settings.
Then go to Other Settings > Rendering and change the Color Space to Linear.

Defining your color space should be one of the earliest decisions in your project, because of the drastic impact on the final shading and lighting results.

Rendering mode.
In the Spotlight Tunnel Sample Scene, we use deferred rendering path. This allows content creators to work with multiple dynamic lights efficiently, combined multiple reflection cubemaps, and have the ability to use the existing Screen Space Reflection features in Unity 2017+.

To set this, go to Graphic Settings > Rendering Path or Camera > Rendering Path

You can find more information about render modes refer in this part of Unity documentation.

High Dynamic Range (HDR) Camera.
When rendering believable lighting, much like in real life, content creators will be dealing with lighting values and emissive surfaces that have a brightness higher than 1 (high dynamic range). These values then need to be remapped to the proper screen range (this is called tonemapping). This setting is crucial to allow the Unity camera to process these high values and not clip them.

To enable this, select the main camera on the scene and ensure that HDR is checked in the inspector tab for the selected camera.

HDR Lightmap encoding. (optional)
The Spotlight Tunnel sample scene didn’t use baked lighting, however, if you’re planning to work with High intensity (HDR) baked lighting, we recommend that you set the lightmap encoding to HDR lightmap to make sure the baked light result is consistent.
The option can be found under Edit > Project > Player settings > Other settings > Lightmap encoding (Unity 2017.3+ only).
Detailed information for Lightmap encoding can be found in the manual.

Tonemapper for your Scene (part of Post Processing Stack).
To display HDR lighting properly, a tonemapper needs to be enabled in the project.
Make sure to install Unity Post Processing Stack (version 1) from the Asset Store first.

Create a Post Process Profile Asset in your project and configure it as follows:

  • Enable Color Grading > Tonemapper > ACES
    (Academy Color Encoding Standards)
  • Enable Dithering. Dithering allows the Scene to alleviate banding artifact introduced by 8 Bit/channel output from HDR Scene. Modern engines use this technique to circumvent the limitation of 16M color output. Leave the rest of settings in tonemapper alone for now.
  • Select the “Main Camera” and add component Post Processing Behaviour.
  • Assign the Post Process profile previously created to the profile slot. If you want to use  Post Processing Stack Version 2, please refer to the readme of the package as it is currently in Beta.
  • Enable Image effect for viewport.
    This enables you to see the tonemapper all the time while working with the Scene view.
    Notice the highlight rendition and the dark tunnel value separation improvements in the tonemapped Scene. If you look at the non-tonemapped Scene, you can see how the highlights didn’t converge to a unified color. (the yellowish burning sun in this case).

This setup essentially tries to replicate how a digital camera captures a scene with a fixed exposure (without exposure adaptation / eye adaptation features enabled).

At this point, content creators have achieved a proper foundational scene rendering setup that should give believable results with a wide range of content.

Lighting and setup

Unity caters to lots of different lighting strategies/systems and project scenarios. We recommend that you check out our extensive documentation on lighting modes and setup to understand all the different options.

However, for fast iteration and simplicity, responsive visual feedback is necessary.
For this reason, the Spotlight Tunnel Sample Scene is using real-time lighting with Realtime Global Illumination (GI). This will give us a nice range of specular response, good bounce lighting, and let us change our lights on the fly.

Realtime lighting with Realtime GI + Light Probe

Going back to the lighting itself, a typical Scene, at daytime, with outdoor areas, can be broken down to 3 lighting components:

  1. Hemisphere (Sky contribution).
  2. Direct lights (Sun + Local lights).
  3. Indirect illumination (GI lighting).

At this stage, content creators are assumed to have meshes that are properly textured, and an assembled Scene.

Outdoor lighting and setup

Initial Hemisphere lighting
First component for outdoor lighting is Hemisphere lighting, called Environment Lighting in Unity. This is a fancy word for skylight. Night sky has minimal contribution, while daytime sky has very bright contribution. Hemisphere settings can be found under the Lighting tab (Window > Lighting > Settings > Environment).
For a start, procedural skybox material would be prefered instead of HDRI cubemap. Create a new material in the project, name it SkyMaterial and then set it to Skybox / Procedural.

Assign it to Environment Skybox Material inside Lighting tab > Scene.

At this point the Scene is somewhat lit. There is ambient, but not exactly proper hemisphere lighting. We’ll leave this alone for now.

Directional Light
Typical sunlight or moonlight is a light source close to infinity distance and has parallel light direction and shadow. They’re usually represented by a directional light.

Indirect Illumination / Global Illumination.
Directional light + ambient alone won’t create believable lighting. Proper hemisphere lighting requires occlusion of the skylight lighting. We also need to simulate sunlight bouncing off subjects in the scene. The sky currently renders a single color value to the Scene making it flat. This is where Realtime Global Illumination or Baked Lighting is required to calculate occlusion and indirect bounce lighting. In order to achieve that, follow these steps:

  • Make sure all meshes that need to contribute to the Realtime GI or baking are flagged with Enable Lightmap Static and Reflection Probe Static. These would typically be large static meshes.
  • Next, enable Realtime Global Illumination (Leave at default-medium settings) in the Lighting tab > Scene > Realtime Lighting.
  • Hit Generate Lighting or check Auto Generate.

Whoa, the Scene is now dark after light generation has finished. To make matters worse, some elements of the Scene are out of place – notice the Tram and the door on the background.
The static objects in the Scene currently have proper occlusion for hemisphere and indirect bounce response from the directional light, however, the rest of the objects lack a proper lighting setup.

Light Probes and Reflection Probes.
For dynamic objects or non-lightmap objects to receive Realtime/Baked Global Illumination, there needs to be light probes distributed in the Scene. Make sure to distribute light probe groups in the Scene efficiently near the areas where dynamically lit objects are located or will pass (such as player). Learn more about Light Probe Group in the manual.
Hit Generate Lighting again or wait for the precomputation to finish if Auto Generate is checked.
The Tram and the background door are grounded better, but reflections look out of place. Sky reflection is all over the place and shows up inside the tunnel. This is where reflection probes comes in. Efficiently place reflection probes with proper coverage in the Scene as needed. In the Scene above, one reflection probe for the main room is sufficient and two for each tunnel interior.
128 pixels Cubemap Resolution using box projection usually is a good baseline for typical cases and will keep memory and reflection bake times happy.
Here’s more information about Reflection Probe.
The Scene now looked properly grounded and cohesive, an important part of a believable Scene. But everything is even darker than before and nowhere near believable quality.

HDR Lighting Value
Many content creators don’t realize that, in reality, hemisphere lighting and sunlight are very bright light sources. They’re much brighter than the value 1. This is where HDR lighting comes into play.

For now, turn off the directional light and then set the SkyMaterial Exposure to 16.
This will give you a good idea what proper hemisphere lighting does to a Scene.
Things start to look believable. Think of this state as a cloudy day, where sunlight is completely diffused in the sky, so there’s no directional light.

At this point, you can reintroduce sunlight back into the Scene at a much higher value. Try Intensity 5 for a start. Despite the sun looking nearly white, it’s important that directional light color is chosen properly as the impact of indirect color from the strong sun can dramatically change the look of the Scene.
Now the sun (directional light) looks like a high energy light as expected from real life. The Scene looks quite believable at this point.

Screen Space Ambient Occlusion and Screen Space Reflection
While the Scene lighting looks pretty good at this point, there’s additional details that you can add to Scene to push it further. Baking detailed occlusion usually isn’t possible because of the limited resolution set in the Realtime GI for reasonable performance. This is where Screen Space Ambient Occlusion can help. Enable SSAO in the Post Process Profile under Ambient occlusion. Settings for this example are set to Intensity 0.5, Radius to 1, Medium Sample count w/ Downsampling and Ambient Only checked for a start.

While SSAO takes care of extra ambient lighting occlusion, reflection could use some accuracy improvements in addition to the simple reflection probes.
Screen Space Raytraced Reflections can helps improve this situation. Enable the Screen Space Reflection in the post process profile.
Notice that the left side of the wet track no longer renders bright reflections as SSR gives the Scene more accurate reflections for on screen objects. Both of these post process effects incur performance costs at runtime, so enable them wisely and set the quality settings to fit within your runtime performance constraints.

At this stage the content creators have achieved somewhat believable outdoor and indoor value separation on a fixed exposure. Reflection is visible in the dark indoor areas as strong highlights and not dim muddy values.

However, the Scene foreground elements and background elements aren’t showing up despite having strong perspective elements. A subtle fog in the Scene can create a massive difference in giving the Scene additional dimension.

Notice the foreground railing has better definition compared to the zero fog Scene.
Fog is enabled in Lighting tab > Scene > Other Settings. Fog color #6D6B4EFF, Exponential at 0.025 density is enabled here. In Unity 2017 deferred rendering, you might also need to enable fog in the post process profile if it’s not activated automatically.

Indoor and local lighting

Spotlight / Pointlight
The staples of real time local lighting are spotlights and pointlights. Area lighting can only be used when baking lighting, unless you’re using the HD Scriptable Render Pipeline (SRP), introduced in 2018.1 beta. There are new area lights that can be rendered in realtime in HD SRP mode.

Fundamentally, both of these types of lights emit light from one point in space and are limited by range with the spotlight having an additional limit by angle. More information about lighting is in the relevant section of Unity docs.

The big differences between the two lights has to do with the way they cast shadows and interact with cookies. Shadowing with a point light costs 6 shadow maps compared to a spotlight’s single shadow map. For this reason shadow casting point lights are much more expensive and should be used very sparingly.

NOTE: Baked lights don’t need to worry about this issue.
Another difference is that a cookie texture on a Spotlight is a simple straight forward 2d texture while a pointlight requires a cubemap, usually authored in 3D software.

Color and Intensity of light.
Choosing the proper color and intensity for your lights needs to follow some loose guidelines to give plausible results.

When selecting intensity for indoor lights, try to make sure no indoor lights have a greater intensity than the sun’s. This can create an unbalanced look depending on the Scene.Given this Sample Scene setting, it’s very unlikely that there’s high intensity lights shining from the ceiling that exceed the brightness of the daylight time.

When selecting color, try not to leave out any one of the color channels completely. This creates a light that has problem converging to the white point.

While it’s technically a valid light color, the light color on the left image removes all blue color from the final output. Having a limited final color palette in the Scene for a baseline isn’t a great idea, especially if you want to do color grading later on.

Emissive Surfaces
In Unity, emissive surfaces can contribute to lighting if Realtime GI or baked GI is enabled, giving the effect of area lighting. This is especially useful if Realtime GI is enabled. Content creators can modify the intensity and color of the emissive surface and get the feedback immediately, assuming that precompute has been done ahead of time.
The image above showcases the subtle diffuse lighting from meshes on the ceiling.

Sample project file

Unity San Francisco Spotlight Team has created the Spotlight Tunnel Sample Scene to help content creators do hands on learning and experimentation.

Get the Spotlight Tunnel Sample project file here.

Simply extract the project to the folder and open the project using Unity.

Spotlight Tunnel Project was made with Unity 2017.1.0f3.

Opening this project in a newer version of Unity will require lighting rebuild as there might be lighting data format incompatibility between versions.

All assets provided in this project may only be used in a project developed with the Unity Engine.

As mentioned before, there are more of things that you need to know about when making believable visuals. You can learn more about this topic in this tutorial. We’re also going to add a full Best Practices Guide to the Unity Docs. Stay tuned!

Now it’s your turn to push the limit.

Hopefully this blog helps content creators to stay on track in achieving believable visuals in Unity. We can’t wait to be dazzled by all Unity content creators out there.


Subscribe to comments

Leave a reply

You may use these HTML tags and attributes: <a href=""> <b> <code> <pre>

  1. Hey there! I’m trying to apply the concepts I’ve learned here to an outdoors scene, but the sun and ambient light always seems too bright, filling the screen with white, if a brightness value of more than 1 is used. The only way I’ve been able to get it back down to believable levels is to use Eye Adaptation + Tonemapping (ACES). Is that what I’m supposed to do, or am I doing something wrong? Thank you!

    1. You certainly need Tonemapping.
      What happened is that the lighting energy is correct, however the exposure in this scene is fixed and not set for outdoor open area.
      I’m guessing if you set your exposure in your exterior scene to be around -3 in Color Grading tab, the lighting would be more acceptable. Eye adaptation certainly can come in handy if you have to traverse for complete open and interior scene such as the SpotlightTunnel Scene.
      In the article, eye adaptation is purposely not explored because of the need to understand and tier the scene lightings in EV Zones.
      That would be another topic that I would like to write sometime in the future if time allowed.
      Hope this helps.

      1. Thank you, that helps a lot!

    1. Thank you for reading the lighting strategy part of the tutorial.
      Lighting strategy often get overlooked and it can mean a difference in fitting your game performance in the target hardware with minimum visual quality compromise.
      There are more lighting strategy that can be done in Unity not mentioned in that tutorial, especially in baking setup to maximize performance with different quality trade off.

  2. This should be the default rendered set on every Unity project. As soon as you create a project as the user if he’s making HD/Console/Desktop project or Mobile project and tune all this settings on automatically. It will make Unity more “out of the box” and gave users better instant look and feeling.

    1. it is, if you open a new project with the ultra template.

    2. The template profile hippocoder mentioned is implemented in Unity 2018.1.

  3. Rinaldo, would you please do a follow up article using exactly the same scene but tuned for a VR experience?

    1. Great idea will certainly consider it for the future.
      The principal of the lighting will be the same and the scene is pretty simple and lightweight, so I don’t expect performance issue.
      However some changes in the post process settings might be needed to accommodate some VR expectation (motion blur, anti-aliasing).
      So give it a shot if you got VR system handy.

  4. One thing which is often missed even by experienced content creators, is that the blue sky itself can’t be used as a skylight. Why? Because the sky looks blue but it actually emits very little blue light. This is easy to test. Put a blank A4 paper under the real sky on a cloudless day. What color does the paper have? Blue-ish or completely white? Now do the same in unity and check the color of the digital piece of paper. It suddenly looks blue. Therefore you should use a white skylight and the blue part should just be used for the background, not for lighting.

    1. Unfortunately, your assumption is incorrect whether its for Unity or any high dynamic range image based lighting engine/renderer out there.
      Simple way of testing it, is to bring mirror ball out in the field on a clear day “with no cloud”.
      Did the ball reflect white sky or blue sky?
      There are many factors that can cause your Unity project or renderer to render blue sky environment lighting to be too blue.
      Typical scenario usually involves wrong tone mapper setup or working with Low dynamic range mode.

      Another issue with the white paper test, is the fact that human brain does advance processing that alter our color perception.
      There’s a good explanation with examples on this perception called “Color Constancy” in wikipedia.
      Hope this helps clarify the confusion.

    2. You’re making an incorrect conclusion from your observation: it doesn’t look blue because your mind auto white balances.
      Try this: look at a white screen in a room lit green, the screen will be magenta, also turn of white balance in your camera and take a snapshot.
      So the correct way to emulate this is to produce a realistic environment and color correct it with the post processing stack.

  5. I tried to create a Procedural Skybox material as described in both 2017.3 and 2018 beta 10 but noticed that the settings are different. In particular, HDR Exposure (which you set to 16) appears to have been replaced with Exposure, which only allows a range from 0-8. Am I missing something?

    1. Thanks for pointing this out.
      I can certainly replicate the discrepancies between the older version vs newer version of Unity.
      Bug is filed for this issue by the QA and we’ll keep you informed.
      In the mean time, if you’re stuck with Exposure 8, under lighting tab > Scene > Environment Lighting > Intensity Multiplier > Set it to 2. It’s not ideal, but will give you somewhat similar result.

      1. Upon further inspection. I have mistaken the use of Skybox-Procedural.shader from Unity Standard Assets vs the one that’s natively built in Unity Empty project (as you’ve spotted, they’re not identical).
        I’ve update The Spotlight Tunnel sample project to include the missing shader and update the material to match the documentation version.
        Please re-download the project from the same link above to get the latest one.
        Once again, thank you for pointing this issue.

  6. Great article, very useful, even for an old user of Unity. Thanks

  7. Thanks for the post, lighting is the most important and hardest aspect of content creation in many regards.

    1. I’m curious what your opinion will be regarding lighting after reading this post.
      It will certainly be a useful feedback for us to improve.

      1. Every time I see a post like this , I improve my understanding of lighting, things like that are very usefull for me, what I would like to see ( because there is a few information on the topic) is a good looking lighting project with a low cost price, for mobile projects

        1. Mobile can mean a lot these days. Some newer devices are very powerful and can actually run this sample project in its current state.
          However, in terms of optimization for mid-tier mobile hardware, there’s certainly a few things that can be done:
          – Converting the lights to be baked (disable Realtime GI since it’s no longer needed if lights are baked).
          – Switch the renderer to forward (be careful with reflection probe coverage since forward has limitation of reflection blending, you’ll also lose the ability to use Screen Space Raytrace Reflection).

          These two alone should be sufficient to make this scene performant on mid-tier mobile hardware.
          Additional optimization would be texture size reduction if memory is a concern.
          The rest of the lighting concept and fundamentals would be the same.

  8. Greate article! A lot can be learned from this.

  9. Thank you! That’s always great to read such best practices from Unity.

    1. Glad you enjoy the post. Don’t forget to check out the full coverage in the tutorial section: