# IntegrateIndirectRadiance(IDeviceContext, int, int, int, bool, BufferSlice<SphericalHarmonicsL2>)

> Computes indirect lighting contribution at probe positions using spherical sampling and path tracing.

## Definition

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

```csharp
IProbeIntegrator.Result IntegrateIndirectRadiance(IDeviceContext context, int positionOffset, int positionCount, int sampleCount, bool ignoreEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut)
```

### Parameters

**** (\[IDeviceContext]\(/engine/6000.6/script-reference/unityengine/lighttransport/idevicecontext)): [IDeviceContext](/engine/6000.6/script-reference/unityengine/lighttransport/idevicecontext.md) 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 samples to take per probe.**** (\[bool]\(https\://learn.microsoft.com/dotnet/api/system.boolean)): If true, excludes environment lighting from the indirect contribution calculation.**** (\[BufferSlice\<SphericalHarmonicsL2>]\(/engine/6000.6/script-reference/unityengine/lighttransport/bufferslice1)): Output [BufferSlice](/engine/6000.6/script-reference/unityengine/lighttransport/bufferslice1.md) that the indirect radiance estimate is written into, encoded as [SphericalHarmonicsL2](/engine/6000.6/script-reference/unityengine/rendering/sphericalharmonicsl2.md).

### Returns

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

### Remarks

This method performs multi-bounce global illumination calculations by tracing rays from each probe position and accumulating light bounces through the scene. The number of bounces is controlled by the bounce count parameter set in [IProbeIntegrator.Prepare](/engine/6000.6/script-reference/unityengine/lighttransport/iprobeintegrator/prepare.md). Higher sample counts and bounce counts significantly improve quality but increase computation time.

### 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);

// Compute indirect lighting
var indirectResult = integrator.IntegrateIndirectRadiance(context, 0, probeCount, 2048, false, indirectBuffer);

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