Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


LightMode

The light mode a light baking backend uses.
Read time 1 minuteLast updated 10 days ago

Definition

public enum LightMode : byte

Remarks

A light can be real-time, mixed, baked or unknown. Unknown lights will be ignored by the baking backends.
The example below uses
LightMode
in a delegate to be used with Lightmapping.SetDelegate. The delegate forces all disc lights in a scene to be baked and all other types of lights to not be baked.
using Unity.Collections;using UnityEngine;using UnityEngine.Experimental.GlobalIllumination;internal static class MyLightBakingUtils{ public static Lightmapping.RequestLightsDelegate BakeOnlyDiscLightsDelegate = (Light[] requests, NativeArray<LightDataGI> lightsOutput) => { LightDataGI lightData = new LightDataGI(); // Iterate over all lights in the scene for (int i = 0; i < requests.Length; i++) { Light light = requests[i]; switch (light.type) { case UnityEngine.LightType.Disc: DiscLight discLight = new DiscLight(); LightmapperUtils.Extract(light, ref discLight); discLight.mode = LightMode.Baked; lightData.Init(ref discLight); break; case UnityEngine.LightType.Spot: case UnityEngine.LightType.Directional: case UnityEngine.LightType.Point: case UnityEngine.LightType.Rectangle: case UnityEngine.LightType.Pyramid: case UnityEngine.LightType.Box: case UnityEngine.LightType.Tube: default: lightData.InitNoBake(light.GetEntityId()); break; } lightsOutput[i] = lightData; } };}
Additional Resources: LightmapBakeType.

Fields

Value

Description

BakedThe light is fully baked and has no real-time component.
MixedThe light is mixed. Mixed lights are interpreted based on the global light mode setting in the lighting window.
RealtimeThe light is real-time. No contribution will be baked in lightmaps or light probes.
UnknownThe light should be ignored by the baking backends.