FalloffType
The falloff models to use for a light baking backend.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Enum
- Namespace: UnityEngine.Experimental.GlobalIllumination
- Assembly: UnityEngine.CoreModule
public enum FalloffType : byte
Remarks
A falloff model describes how light intensity diminishes (falls off) with distance from the source.
This enumeration allows SRPs or custom lighting implementations to specify explicitly how lights should behave when processed by the Global Illumination light baking backends.
The example below uses in a delegate to be used with Lightmapping.SetDelegate. The delegate forces all disc lights in a scene to be baked with a falloff model of .
FalloffTypeInverseSquaredExamples
using Unity.Collections;using UnityEngine;using UnityEngine.Experimental.GlobalIllumination;internal static class MyLightBakingUtils{ public static Lightmapping.RequestLightsDelegate BakeFalloffInverseSquaredDelegate = (Light[] requests, NativeArray<LightDataGI> lightsOutput) => { LightDataGI lightData = new (); // 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; } lightData.falloff = FalloffType.InverseSquared; lightsOutput[i] = lightData; } };}
Fields
Value | Description |
|---|---|
| InverseSquared | Inverse squared distance falloff model. |
| InverseSquaredNoRangeAttenuation | Inverse squared distance falloff model (without smooth range attenuation). |
| Legacy | Quadratic falloff model. |
| Linear | Linear falloff model. |
| Undefined | Falloff model is undefined. |