Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


FalloffType

The falloff models to use for a light baking backend.
Read time 1 minuteLast updated 10 days ago

Definition

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
FalloffType
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
InverseSquared
.

Examples

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

InverseSquaredInverse squared distance falloff model.
InverseSquaredNoRangeAttenuationInverse squared distance falloff model (without smooth range attenuation).
LegacyQuadratic falloff model.
LinearLinear falloff model.
UndefinedFalloff model is undefined.