ComputeOcclusionLightIndicesFromBakeInput(BakeInput, Vector3[], uint)
Determines the most influential lights for occlusion calculations at each probe position.
阅读时间1 分钟最后更新于 1 个月前
Definition
- Type: Method
- Namespace: UnityEngine.LightTransport
- Assembly: UnityEditor.CoreModule
public static int[] ComputeOcclusionLightIndicesFromBakeInput(InputExtraction.BakeInput bakeInput, Vector3[] probePositions, uint maxLightsPerProbe = 4)
Parameters
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);