Version: Unity 6 (6000.0)
Language : English
Bake different lighting setups with Lighting Scenarios
Optimize loading Adaptive Probe Volume data

Update light from the sky at runtime with sky occlusion

You can enable sky occlusion when you use Adaptive Probe Volumes. Sky occlusion means that when a GameObjectThe fundamental object in Unity scenes, which can represent characters, props, scenery, cameras, waypoints, and more. A GameObject’s functionality is defined by the Components attached to it. More info
See in Glossary
samples a color from the sky, Unity dims the color if the light can’t reach the GameObject.

Sky occlusion in Unity uses the sky color from the ambient probe, which updates at runtime. This means you can dynamically light GameObjects as the sky color changes. For example, you can change the sky color from light to dark, to simulate the effect of a day-night cycle.

If you enable sky occlusion, Adaptive Probe Volumes might take longer to bake, and Unity might use more memory at runtime.

How sky occlusion works

When you enable sky occlusion, Unity bakes an additional static sky occlusion value into each probe in an Adaptive Probe Volume. The sky occlusion value is the amount of indirect light the probe receives from the sky, including light that bounced off static GamesObjects.

At runtime, when a static or dynamic GameObject samples an Adaptive Probe Volume probe, Unity approximates the light from the sky using two values:

  • A sky color from the ambient probe, which updates when the sky color changes.
  • The sky occlusion value, which is static.

Enable sky occlusion

First, enable the GPU lightmapperA tool in Unity that bakes lightmaps according to the arrangement of lights and geometry in your scene. More info
See in Glossary
. Unity doesn’t support sky occlusion if you use Progressive CPU instead.

  1. Go to Window > Rendering > Lighting.
  2. Go to the SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
    See in Glossary
    panel.
  3. Set Lightmapper to Progressive GPU.

To enable sky occlusion, follow these steps:

  1. Go to the Adaptive Probe Volumes panel.
  2. Enable Sky Occlusion.

To update the lighting data, you must also bake the Adaptive Probe Volume after you enable or disable sky occlusion.

Update light at runtime

To update light from the sky at runtime, you must use colors for the ambient lightLight that doesn’t come from any specific direction, and contributes equal light in all directions to the Scene. More info
See in Glossary
in your scene, not a skyboxA special type of Material used to represent skies. Usually six-sided. More info
See in Glossary
. To use colors, do the following:

  1. Go to Window > Rendering > Lighting.
  2. Go to the Environment panel.
  3. Set Source to either Gradient or Color.

To update the light from the sky at runtime, do either of the following:

Enable more accurate sky direction data

When an object samples the ambient probe, by default Unity uses the surface normal of the object as the direction to the sky. This direction might not match the direction the light comes from, for example if the object is inside and the sky light bounces off other objects to reach it.

Unity can instead calculate, store, and use an accurate direction from each Adaptive Probe Volume probe, and take bounce lighting into account. This makes sky occlusion more accurate, especially in areas like caves where probes don’t have a direct line of sight to the sky, or when the sky has contrasting colors and the light comes from a specific direction such as through a window.

To enable this feature, in the Adaptive Probe Volumes of the Lighting window, enable Sky Direction.

If you enable Sky Direction, the following applies:

  • Baking takes longer and Unity uses more memory at runtime.
  • There might be visible seams, because Unity doesn’t interpolate sky direction data between probes.

To override the directions Unity uses, use a Probe Adjustment Volume component.

Additional resources

Bake different lighting setups with Lighting Scenarios
Optimize loading Adaptive Probe Volume data