IntegrateIndirectRadiance(IDeviceContext, int, int, int, bool, BufferSlice<SphericalHarmonicsL2>)
Computes indirect lighting contribution at probe positions using spherical sampling and path tracing.
Read time 2 minutesLast updated 13 days ago
Definition
- Type: Method
- Namespace: UnityEngine.LightTransport
- Assembly: UnityEditor
IProbeIntegrator.Result IntegrateIndirectRadiance(IDeviceContext context, int positionOffset, int positionCount, int sampleCount, bool ignoreEnvironment, BufferSlice<SphericalHarmonicsL2> radianceEstimateOut)
Parameters
Device context for computation and memory operations.
Starting index in the probe position buffer.
Number of probe positions to process.
Number of samples to take per probe.
If true, excludes environment lighting from the indirect contribution calculation.
Output buffer slice that the indirect radiance estimate is written into, encoded as spherical harmonics coefficients.
Returns
Type | Description |
|---|---|
| Result | 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.
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
// Extract scene databool result = InputExtraction.ExtractFromScene(out var input);Assert.IsTrue(result);// Create context and worldusing var context = new RadeonRaysContext();Assert.IsTrue(context.Initialize());var world = new RadeonRaysWorld();// Populate world with scene datausing var progress = new BakeProgressState();var worldResult = InputExtraction.PopulateWorld(input, progress, context, world);Assert.IsTrue(worldResult);// Create integratorvar integrator = new RadeonRaysProbeIntegrator();integrator.SetProgressReporter(progress);// Prepare probe positionsvar probePositions = new NativeArray<Vector3>(64, Allocator.Persistent);// ... fill probe positions ...BufferID posBuffer = context.CreateBuffer(64, 12); // Vector3 = 12 bytesvar posSlice = new BufferSlice<Vector3>(posBuffer, 0);context.WriteBuffer(posSlice, probePositions);// Prepare integrator.integrator.Prepare(context, world, posSlice, 0.1f, 2);// Compute indirect lightingvar indirectResult = integrator.IntegrateIndirectRadiance(context, 0, probeCount, 2048, false, indirectBuffer);// Cleanupintegrator.Dispose();context.DestroyBuffer(posBuffer);context.DestroyBuffer(indirectBuffer);probePositions.Dispose();