|
1 |
| -# Sky Occlusion |
| 1 | +# Update light from the sky at runtime with sky occlusion |
2 | 2 |
|
3 |
| -Sky Occlusion stores the amount of lighting from the Sky affecting probes in an Adaptive Probe Volume. During run-time, this data can be combined with lighting from the Scene’s Ambient Probe to dynamically relight the Scene based on changes to the Sky. See [Visual Environment Volume override](Override-Visual-Environment.md). |
| 3 | +You can enable sky occlusion when you use Adaptive Probe Volumes. Sky occlusion means that when a GameObject samples a color from the sky, Unity dims the color if the light can't reach the GameObject. |
4 | 4 |
|
5 |
| -When Sky Occlusion is enabled for Adaptive Probe Volumes, an additional directional visibility factor is calculated for each probe during bake time. This gray value - stored as a spherical harmonic - is used during shading to attenuate the lighting contribution from the Sky. As multiple bounces can be used, the Sky’s effect upon probes with indirect paths to the Sky can also be calculated. |
| 5 | +Sky occlusion in Unity uses the sky color from the [ambient probe](https://docs.unity3d.com/2023.3/Documentation/ScriptReference/RenderSettings-ambientProbe.html), 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. |
6 | 6 |
|
7 |
| -Static and dynamic objects can both receive lighting with Sky Occlusion. However, only static objects can affect the baked result. Enabling Sky Occlusion can lengthen the time required to bake lighting and uses additional memory at run-time. |
| 7 | +If you enable sky occlusion, Adaptive Probe Volumes might take longer to bake, and Unity might use more memory at runtime. |
8 | 8 |
|
9 |
| -## Enable Sky Occlusion |
| 9 | +## How sky occlusion works |
10 | 10 |
|
11 |
| -Sky Occlusion is enabled from the **Sky Occlusion** section of the **Adaptive Probe Volumes** tab within the **Lighting Window**. |
| 11 | +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. |
12 | 12 |
|
13 |
| -Note that lighting data must be recalculated if Sky Occlusion is enabled for the first time, or is disabled following a bake. |
| 13 | +At runtime, when a static or dynamic GameObject samples an Adaptive Probe Volume probe, Unity approximates the light from the sky using two values: |
14 | 14 |
|
15 |
| -## Modifying Sky Occlusion properties |
| 15 | +- A sky color from the ambient probe, which updates when the sky color changes. |
| 16 | +- The sky occlusion value, which is static. |
16 | 17 |
|
17 |
| -It is possible to affect the visual quality and appearance of Sky Occlusion using these properties: |
| 18 | +## Enable sky occlusion |
18 | 19 |
|
19 |
| -<table> |
20 |
| - <thead> |
21 |
| - <tr> |
22 |
| - <th><strong>Property</strong></th> |
23 |
| - <th colspan="2"><strong>Description</strong></th> |
24 |
| - </tr> |
25 |
| - </thead> |
26 |
| - <tbody> |
27 |
| - <tr> |
28 |
| - <td><strong>Samples</strong></td> |
29 |
| - <td>Determines the number of samples used when calculating the sky contribution for each probe. Increasing this value improves the accuracy of lighting data at the cost of the time required to bake Adaptive Probe Volumes.</td> |
30 |
| - </tr> |
31 |
| - <tr> |
32 |
| - <td><b>Bounces</b></td> |
33 |
| - <td>The number of bounces used when calculating the sky’s contribution on probes. Increasing the number of bounces can be useful in Scenes where probes may have very indirect routes to the Sky. This will also affect the time required to bake Adaptive Probe Volumes.</td> |
34 |
| - </tr> |
35 |
| - <tr> |
36 |
| - <td><strong>Albedo Override</strong></td> |
37 |
| - <td>Sky Occlusion does not consider the albedo (color) of Materials used throughout the Scene when calculating bounced lighting. Instead a single color is a used throughout the Scene. Albedo Override allows this color to be modified. Lower values darken and higher values will brighten the intensity of this value.</td> |
38 |
| - </tr> |
39 |
| - <tr> |
40 |
| - <td><b>Sky Direction</b></td> |
41 |
| - <td>Whether probes should store the dominant direction of incoming light from the Sky. Sky Direction increases memory usage but produces more accurate lighting. Without Sky Direction, the surface normals of objects are used instead and in some Scenes this can produce visual inaccuracies.</td> |
42 |
| - </tr> |
43 |
| - </tbody> |
44 |
| -</table> |
| 20 | +First, enable the GPU lightmapper. Unity doesn't support sky occlusion if you use **Progressive CPU** instead. |
45 | 21 |
|
46 |
| -## Sky Direction |
| 22 | +1. Go to **Window** > **Rendering** > **Lighting**. |
| 23 | +2. Go to the **Scene** panel. |
| 24 | +3. Set **Lightmapper** to **Progressive GPU**. |
47 | 25 |
|
48 |
| -By default, Sky Direction is disabled and the surface normals of objects lit by probes are used to sample the Ambient Probe generated from the Sky. |
49 |
| -When Sky Direction is enabled, Unity calculates - for each probe - the most appropriate incoming sky lighting direction. Where desirable, this can be locally overridden in specific areas of the Scene using a [Probe Adjustment Volume](probevolumes-concept.md#volume). |
| 26 | +To enable sky occlusion, follow these steps: |
50 | 27 |
|
51 |
| -Enabling Sky Direction can improve visual results, especially in cave-like scenarios where the sky lighting needs to bounce several times on surfaces before reaching a surface. However the additional data required increases the time needed to bakelighting data. It also increases memory usage during run-time. |
| 28 | +1. Go to the **Adaptive Probe Volumes** panel. |
| 29 | +2. Enable **Sky Occlusion**. |
52 | 30 |
|
53 |
| -## Debugging Sky Occlusion |
| 31 | +To update the lighting data, you must also [bake the Adaptive Probe Volume](probevolumes-use.md#add-and-bake-an-adaptive-probe-volume) after you enable or disable sky occlusion. |
54 | 32 |
|
55 |
| -You can inspect the Sky Occlusion value using the **Display Probes** option in the [Rendering Debugger](rendering-debugger-window-reference.md#probe-volume-panel). Two views are provided in the **Probe Shading Mode** dropdown: |
56 |
| -1. **Sky Occlusion SH**: Display the gray value (scalar) used to attenuate Sky lighting. |
57 |
| -2. **Sky Direction**: Displays a green dot corresponding to the direction used to sample the Ambient Probe. If **Sky Direction** was not enabled or could not be computed this displays a red probe. |
| 33 | +## Update light at runtime |
58 | 34 |
|
59 |
| -## Limitations |
| 35 | +To update the light from the sky at runtime, follow these steps to make sure the ambient probe updates when the sky updates. |
60 | 36 |
|
61 |
| -1. Currently Sky Occlusion does not work if the **Progressive CPU Lightmapper** is selected. |
62 |
| -2. If Sky Occlusion is enabled or disabled, the Scene must be rebaked to update lighting data. |
63 |
| -3. Sky Direction is not interpolated between probes. This may result in harsh lighting transitions where neighboring probes are storing very different results. |
| 37 | +1. In the **Hierarchy** window, select the volume that affects the current camera. |
| 38 | +2. In the **Inspector** window, double-click the Volume Profile Asset to open the asset. |
| 39 | +3. In the **Visual Environment** > **Sky** section, set **Ambient Mode** to **Dynamic**. |
64 | 40 |
|
65 |
| -# Additional resources |
| 41 | +Refer to [Environment lighting](environment-lighting.md) for more information. |
66 | 42 |
|
| 43 | +## Enable more accurate sky direction data |
67 | 44 |
|
| 45 | +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. |
68 | 46 |
|
69 |
| -* [Understand Adaptive Probe Volumes](probevolumes-concept.md) |
70 |
| -* [Visual Environment Volume override](Override-Visual-Environment.md) |
| 47 | +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. |
| 48 | + |
| 49 | +To enable this feature, in the **Adaptive Probe Volumes** of the Lighting window, enable **Sky Direction**. |
| 50 | + |
| 51 | +If you enable **Sky Direction**, the following applies: |
| 52 | + |
| 53 | +- Baking takes longer and Unity uses more memory at runtime. |
| 54 | +- There might be visible seams, because Unity doesn't interpolate sky direction data between probes. |
| 55 | + |
| 56 | +To override the directions Unity uses, use a [Probe Adjustment Volume component](probevolumes-adjustment-volume-component-reference.md). |
| 57 | + |
| 58 | +## Additional resources |
| 59 | + |
| 60 | +- [Adaptive Probe Volumes panel properties](probevolumes-lighting-panel-reference.md#sky-occlusion-settings) for more information about sky occlusion settings |
| 61 | +- [Rendering Debugger](rendering-debugger-window-reference.md#probe-volume-panel) for information about displaying baked sky occlusion data |
0 commit comments