# 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.3/script-reference/unityengine/lighttransport.md)
* **Assembly:** UnityEditor

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

### 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 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.3/script-reference/unityengine/lighttransport/bufferslice1)): Output buffer slice that the indirect radiance estimate is written into, encoded as spherical harmonics coefficients.

### 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 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.3/script-reference/unityengine/lighttransport/iprobeintegrator/prepare.md).

Indirect radiance includes contribution from:

* Light bounced off surfaces.
* Light transmitted through transparent materials.
* Illumination from emissive materials.
* Multi-bounce environment lighting.

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();
```
