Lighting Settings

Verificado com a versão: 2018.1


Dificuldade: Avançado

The Lighting Window (menu: Window > Lighting > Settings) contains various options that control the appearance of lighting.

The Scene tab of the Lighting Window allows you to apply lighting options to specific Scenes, rather than to the whole Project. These are known as Scene lighting settings. Unexpected lighting results can occur when Unity has more than one Scene open, and those Scenes have different Scene lighting settings. This can happen when you use Multi-Scene editing in Edit Mode, or when you additively load Scenes in Edit Mode, Play Mode, or a built Project.

When handling multiple Scene lighting settings, Unity is able to combine some settings without problems but must completely overwrite or merge others. Understanding which lighting settings are unaffected, which are overwritten, and which are merged is crucial to lighting multiple Scenes.

  • Global Settings are settings that Unity merges or overwrites when loading multiple Scenes.

  • Scene-dependent Settings are settings that are unaffected when Unity loads multiple Scenes.

Global Settings

The following settings are Global:

  • All settings in the Environment section

  • Realtime Global Illumination

  • Mixed Lighting

  • Lighting mode

  • Directional Mode

  • Indirect intensity

  • Albedo Boost

  • All settings in the Other Settings section

  • Auto Generation

Carefully consider these when you use Multi-Scene editing or additive loading. When multiple Scenes are open, and those Scenes have conflicting Global settings, Unity merges or overwrites these settings. This can lead to unexpected lighting results. As such, Scenes that Unity additively loads at the same time in Play mode should use identical Global settings.

When multiple Scenes are open, the Global settings of whichever Scene Unity loads first become the default Global settings. These default Global settings are the base settings for any subsequent additively loaded Scenes, which Unity then adds or merges data. This persists until you set another Scene as active (by destructively loading another Scene or by calling SceneManager.SetActiveScene()). At this point, the active Scene's Global settings become the default.

Any new Scene which Unity loads additively merges its GI data into the existing one. For example, Scene A has a daytime skybox, and Scene B has a night-time skybox. If you load Scene A first, and then additively load Scene B, Unity uses the sunny skybox for both.

Scenarios involving Realtime Global Illumination are particularly complex. To expand on the above example, let's say that Scene A (with the daylight skybox) and Scene B (with the night-time skybox) both use Realtime GI. If you load Scene A first and then additively load Scene B, Scene B incorporates the new environment lighting correctly and appears with daylight conditions. However, if Scene A has Realtime GI disabled, the additive result is a daylight environment with Scene B still showing baked night-time results.

The setting Realtime Global Illumination is a Global Setting as well. If you disable Realtime GIobal Illumination in a Scene, and additively load another Scene that has Realtime GI enabled while it generates its lighting, it only uses the baked results if attainable. Similarly, the effects of Directional mode vanishes when the active Scene does not have Directional mode enabled. Directional mode requires an additional Texture, and dismisses it if the mode is disabled in the active Scene.

Scene-dependent Settings

You can combine specific Lighting Settings appropriately. The following settings are Scene-dependent and do not affect other Scenes after a successful bake:

  • All settings of the Progressive Lightmapper

  • Lightmap Resolution

  • Lightmap Padding

  • Lightmap Size

  • Compress Lightmap

  • Ambient Occlusion

  • Final Gather

For example, Unity safely combines a Scene baked with a Lightmap Size of 1024 with a Scene baked with a Lightmap Size of 512. This is because the lightmap resolution after the bake is no longer relevant because the result is a texture that the Unity runtime uses. If you want to use lightmaps of different resolutions you may want to examine the Lightmap Switching Tool.

Please note that if more than one Scene is open in the Editor, the Lighting Settings Inspector shows only the settings for the "main" Scene - that is, the Scene that Unity loads first, or whichever one you have subsequently set as the active Scene.