Prepare(IDeviceContext, IWorld, BufferSlice<Vector3>, float, int)
Initializes the probe integrator with scene data and integration parameters.
Read time 1 minuteLast updated 10 days ago
Definition
- Type: Method
- Namespace: UnityEngine.LightTransport
- Assembly: UnityEngine.CoreModule
void Prepare(IDeviceContext context, IWorld world, BufferSlice<Vector3> positions, float pushoff, int bounceCount)
Parameters
IDeviceContext for computation and memory operations.
World object containing the scene geometry and other input data.
BufferSlice containing the 3D positions of the light probes to be integrated.
Distance to offset rays from probe positions to avoid self-intersection artifacts.
Maximum number of light bounces for indirect lighting calculations.
Remarks
This method must be called before any integration operations. It prepares internal data structures, compiles shaders if necessary, and sets up the integration parameters.
The preparation phase can be time-intensive for large scenes as it may involve:
- Building acceleration structures.
- Compiling compute shaders for the target device.
- Preprocessing scene geometry and materials.
- Setting up light data structures.
The pushoff parameter helps prevent ray self-intersections when probes are placed very close to surfaces.
Examples
// Create probe positions buffervar probePositions = new NativeArray<Vector3>(numProbes, Allocator.Persistent);// ... populate positions ...BufferID posBuffer = context.CreateBuffer((ulong)numProbes, 12);var posSlice = new BufferSlice<Vector3>(posBuffer, 0);context.WriteBuffer(posSlice, probePositions);context.Flush();// Prepare integrator with 2 bounce indirect lightingintegrator.Prepare( context, world, posSlice, 0.05f, // 5cm push-off to avoid self-intersection 2 // 2 bounce indirect lighting);// Now ready for integration operationsvar result = integrator.IntegrateDirectRadiance(context, 0, numProbes, 1024, false, outputBuffer);