Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ComputeOcclusionLightIndicesFromBakeInput(BakeInput, Vector3[], uint)

Determines the most influential lights for occlusion calculations at each probe position.
Read time 1 minuteLast updated 13 days ago

Definition

public static int[] ComputeOcclusionLightIndicesFromBakeInput(InputExtraction.BakeInput bakeInput, Vector3[] probePositions, uint maxLightsPerProbe = 4)

Parameters

bakeInput

The BakeInput containing light source information.

probePositions

Array of world-space positions where occlusion should be computed.

maxLightsPerProbe

Maximum number of lights to select per probe (typically 4 for shadowmask compatibility).

Returns

Type

Description

int[]Flattened array of light indices where each consecutive group of maxLightsPerProbe indices corresponds to one probe position.

Remarks

This method analyzes the light sources in the scene and selects the most influential ones for each probe position.
The returned indices are used with IProbeIntegrator.IntegrateOcclusion to compute shadow mask data for mixed lighting mode.
Array Layout: For N probes and M lights per probe, the result contains N × M indices where indices [I × M to (I + 1) × M - 1] belong to probe i.
Additional Resources: IProbeIntegrator.IntegrateOcclusion, GetShadowmaskChannelsFromLightIndices.

Examples

// Extract probe positions from light probe groupsvar probePositions = new List<Vector3>();var lightProbeGroups = FindObjectsOfType<LightProbeGroup>();foreach (var group in lightProbeGroups){ probePositions.AddRange(group.probePositions.Select(p => group.transform.TransformPoint(p)));}// Compute light indices for shadowmask occlusionvar lightIndices = InputExtraction.ComputeOcclusionLightIndicesFromBakeInput( bakeInput, probePositions.ToArray(), 4 // 4 lights per probe for RGBA shadowmask);// Get corresponding shadowmask channelsvar shadowmaskChannels = InputExtraction.GetShadowmaskChannelsFromLightIndices(bakeInput, lightIndices);// Use with integratorvar result = integrator.IntegrateOcclusion(context, 0, probePositions.Count, 512, 4, lightIndexBuffer, occlusionBuffer);