# IntegrateOcclusion(IDeviceContext, int, int, int, int, BufferSlice<int>, BufferSlice<float>)

> Computes occlusion values for mixed lighting scenarios with shadowmask support.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine.LightTransport](/engine/6000.3/script-reference/unityengine/lighttransport.md)
* **Assembly:** UnityEditor

```csharp
IProbeIntegrator.Result IntegrateOcclusion(IDeviceContext context, int positionOffset, int positionCount, int sampleCount, int maxLightsPerProbe, BufferSlice<int> perProbeLightIndices, BufferSlice<float> probeOcclusionEstimateOut)
```

### Parameters

**** (\[IDeviceContext]\(/engine/6000.3/script-reference/unityengine/lighttransport/idevicecontext)): Device context for computation and memory operations.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Starting index in the probe position buffer.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Number of probe positions to process.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Number of directional samples to take per probe.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Maximum number of lights to compute occlusion for per probe (typically 4).**** (\[BufferSlice\<int>]\(/engine/6000.3/script-reference/unityengine/lighttransport/bufferslice1)): Buffer containing light indices for each probe, computed using ComputeOcclusionLightIndicesFromBakeInput.**** (\[BufferSlice\<float>]\(/engine/6000.3/script-reference/unityengine/lighttransport/bufferslice1)): Output buffer for occlusion values. Size must be positionCount × maxLightsPerProbe × sizeof(float).

### Returns

| Type                                                                                            | Description                                                           |
| ----------------------------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Result](/engine/6000.3/script-reference/unityengine/lighttransport/iprobeintegrator/result.md) | Result indicating success or failure with detailed error information. |

### Remarks

This method computes occlusion factors for mixed lights at each probe position. Mixed lights are lights that provide both real-time dynamic lighting and baked shadows through shadowmasks.

The occlusion calculation:

* Value 1.0: No occlusion (light is fully visible).
* Values between 0-1: Partial occlusion.
* Value 0.0: Full occlusion (light is completely blocked).

The light indices can be precomputed using ComputeOcclusionLightIndicesFromBakeInput to select the most influential lights for each probe position.

Additional Resources: ComputeOcclusionLightIndicesFromBakeInput, GetShadowmaskChannelsFromLightIndices.

### Examples

```csharp
// Compute light indices for occlusion
var probePositions = GetProbePositions(); // Vector3[]
var lightIndices = InputExtraction.ComputeOcclusionLightIndicesFromBakeInput(bakeInput, probePositions, 4);

// Create buffer for light indices
BufferID lightIndexBuffer = context.CreateBuffer((ulong)(probePositions.Length * 4), sizeof(int));
var lightIndexSlice = new BufferSlice<int>(lightIndexBuffer, 0);
context.WriteBuffer(lightIndexSlice, new NativeArray<int>(lightIndices, Allocator.Temp));

// Create output buffer for occlusion values
BufferID occlusionBuffer = context.CreateBuffer((ulong)(probePositions.Length * 4), sizeof(float));
var occlusionSlice = new BufferSlice<float>(occlusionBuffer, 0);

// Compute occlusion
var result = integrator.IntegrateOcclusion(context, 0, probePositions.Length, 512, 4, lightIndexSlice, occlusionSlice);

Assert.AreEqual(IProbeIntegrator.ResultType.Success, result.type);
```
