# IProbeIntegrator

> Interface for light probe integration operations, typically used for global illumination baking.

## Definition

* **Type:** Interface
* **Namespace:** [UnityEngine.LightTransport](/engine/6000.5/script-reference/unityengine/lighttransport.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public interface IProbeIntegrator : IDisposable
```

## Remarks

The IProbeIntegrator interface provides methods for computing various lighting contributions at light probe positions, including direct radiance, indirect radiance, occlusion, and validity. These operations are essential for baking light probes in Unity's lighting system.

Unity provides a concrete implementation of this interface:

* [RadeonRaysProbeIntegrator](/engine/6000.5/script-reference/unityengine/lighttransport/radeonraysprobeintegrator.md) for GPU-accelerated integration using OpenCL 1.2.

The integrator operates on light probe positions and encodes lighting results as [SphericalHarmonicsL2](/engine/6000.5/script-reference/unityengine/rendering/sphericalharmonicsl2.md). For mixed lighting scenarios Unity can integrate occlusion values.

## Examples

```csharp
// Extract scene data
bool result = InputExtraction.ExtractFromScene(out var input);
Assert.IsTrue(result);

// Create context and world
using var context = new RadeonRaysContext();
Assert.IsTrue(context.Initialize());
var world = new RadeonRaysWorld();

// Populate world with scene data
using var progress = new BakeProgressState();
var worldResult = InputExtraction.PopulateWorld(input, progress, context, world);
Assert.IsTrue(worldResult);

// Create integrator
var integrator = new RadeonRaysProbeIntegrator();
integrator.SetProgressReporter(progress);

// Prepare probe positions
var probePositions = new NativeArray<Vector3>(64, Allocator.Persistent);
// ... fill probe positions ...

BufferID posBuffer = context.CreateBuffer(64, 12); // Vector3 = 12 bytes
var posSlice = new BufferSlice<Vector3>(posBuffer, 0);
context.WriteBuffer(posSlice, probePositions);

// Prepare integrator
integrator.Prepare(context, world, posSlice, 0.1f, 2);

// Create output buffer for direct and indirect radiance encoded as L2 spherical harmonics.
BufferID shBuffer = context.CreateBuffer(64, 108); // SHL2 = 108 bytes
var shSlice = new BufferSlice<SphericalHarmonicsL2>(shBuffer, 0);
BufferID shBufferIndirect = context.CreateBuffer(64, 108); // SHL2 = 108 bytes
var shSliceIndirect = new BufferSlice<SphericalHarmonicsL2>(shBuffer, 0);

// Integrate direct lighting
var directResult = integrator.IntegrateDirectRadiance(context, 0, 64, 128, false, shSlice);
Assert.AreEqual(IProbeIntegrator.ResultType.Success, directResult.type);

// Integrate indirect lighting
var indirectResult = integrator.IntegrateIndirectRadiance(context, 0, 64, 2048, false, shSliceIndirect);
Assert.AreEqual(IProbeIntegrator.ResultType.Success, indirectResult.type);

// Combine direct and indirect results if needed using the IProbePostProcessor interface.

// Cleanup
integrator.Dispose();
context.DestroyBuffer(posBuffer);
context.DestroyBuffer(shBuffer);
context.DestroyBuffer(shBufferIndirect);
probePositions.Dispose();
```

## Methods

| Method                                                                                                                                | Description                                                                                           |
| ------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- |
| [IntegrateDirectRadiance](/engine/6000.5/script-reference/unityengine/lighttransport/iprobeintegrator/integratedirectradiance.md)     | Computes direct lighting contribution at probe positions using spherical sampling.                    |
| [IntegrateIndirectRadiance](/engine/6000.5/script-reference/unityengine/lighttransport/iprobeintegrator/integrateindirectradiance.md) | Computes indirect lighting contribution at probe positions using spherical sampling and path tracing. |
| [IntegrateOcclusion](/engine/6000.5/script-reference/unityengine/lighttransport/iprobeintegrator/integrateocclusion.md)               | Computes occlusion values for mixed lighting scenarios with shadowmask support.                       |
| [IntegrateValidity](/engine/6000.5/script-reference/unityengine/lighttransport/iprobeintegrator/integratevalidity.md)                 | Computes validity factors indicating the reliability of each probe position.                          |
| [Prepare](/engine/6000.5/script-reference/unityengine/lighttransport/iprobeintegrator/prepare.md)                                     | Initializes the probe integrator with scene data and integration parameters.                          |
| [SetProgressReporter](/engine/6000.5/script-reference/unityengine/lighttransport/iprobeintegrator/setprogressreporter.md)             | Configures progress tracking for integration operations.                                              |

## Structs

| Struct                                                                                                           | Description                                                                              |
| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| [IProbeIntegrator.Result](/engine/6000.5/script-reference/unityengine/lighttransport/iprobeintegrator/result.md) | The type returned by the probe integrator. The type contains detailed error information. |

## Enums

| Enum                                                                                                                     | Description                        |
| ------------------------------------------------------------------------------------------------------------------------ | ---------------------------------- |
| [IProbeIntegrator.ResultType](/engine/6000.5/script-reference/unityengine/lighttransport/iprobeintegrator/resulttype.md) | Result of an integrator operation. |

## Inheritance

**Inherited Members:**

* [IDisposable.Dispose()](https://learn.microsoft.com/dotnet/api/system.idisposable.dispose)
