step method
Runs the next batch of probes. Returns the finished IrradianceFieldBake on completion, or null while more steps remain.
Implementation
IrradianceFieldBake? step() {
if (isDone) return _finalize();
final end = math.min(_totalProbes, _currentProbe + probesPerStep);
final fov = 2.0 * math.atan(1.0 / cubeFaceOverscan(faceResolution));
final size = ui.Size(faceResolution.toDouble(), faceResolution.toDouble());
for (var i = _currentProbe; i < end; i++) {
final slotZ =
i ~/ (layout.resolution.x.toInt() * layout.resolution.y.toInt());
final rem =
i % (layout.resolution.x.toInt() * layout.resolution.y.toInt());
final slotY = rem ~/ layout.resolution.x.toInt();
final slotX = rem % layout.resolution.x.toInt();
final worldPos =
origin +
Vector3(slotX * spacing.x, slotY * spacing.y, slotZ * spacing.z);
final faces = <gpu.Texture>[];
for (final (forward, up) in cubeFaceBases) {
final face = createHdrCaptureTarget(faceResolution);
_pool.beginFrame();
_renderView(
view: RenderView(
camera: PerspectiveCamera(
fovRadiansY: fov,
position: worldPos,
target: worldPos + forward,
up: up,
),
layerMask: layerMask,
),
outputColor: face,
pixelSize: size,
pool: _pool,
environmentMap: environmentMap,
transientsBuffer: transientsBuffer,
lightComponent: lightComponent,
punctualLighting: punctualLighting,
spotShadowFrame: spotShadowFrame,
captureLinearColor: true,
);
faces.add(face);
}
_convolveProbe(probeIndex: i, faces: faces);
}
_currentProbe = end;
if (isDone) return _finalize();
return null;
}