Lighting Settings

Revisado con versión: 2018.1


Dificultad: Avanzado

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 set lighting options that are applied 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, in Play Mode or in 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 must be either merged or overwritten when multiple Scenes are loaded.

Scene-dependent Settings are settings that are unaffected when multiple Scenes are loaded.

Global Settings

When multiple Scenes are open and those Scenes have conflicting Global Settings, Unity must merge or overwrite these settings. This can lead to unexpected lighting results, and should be avoided. As such, Scenes that are additively loaded at the same time in Play Mode should use identical Global Settings.

Carefully consider the following list of settings when you use Multi-Scene editing or additive loading:

  • 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

When multiple Scenes are open, the Global Settings of whichever Scene Unity loads first becomes the default Global Settings. These default Global Settings are the base settings for any subsequent additively loaded Scenes, to which their data must be merged or added. 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.

For example, Scene A has a sunny skybox and Scene B has a nighttime skybox. If you load Scene A first and then you additively load Scene B, the sunny skybox is used for both.

Any new Scene which Unity loads additively merges its GI data into the existing one.

Scenarios involving Realtime Global Illumination is particularly complex. To expand on the above example, let's say that Scene A (with the sunny 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 sunny conditions. However, if Scene A has Realtime GI disabled, the additive result is a sunny environment with Scene B still showing baked night-sky results.

The setting Realtime Global Illumination is a Global Setting as well. If you disable Realtime GI 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 this 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: i.e., the Scene that Unity loads first, or whichever one you have subsequently set as the active Scene.