RRSolver class is your primary interface to Lightsprint engine. To add global illumination to your application,
- Create instance of RRSolver or its subclass (e.g. RRSolverGL).
- Set static objects once, call RRSolver::setStaticObjects() with set of static objects participating in calculation. This call is expensive, design your application to minimize changes to static scene.
- Set dynamic objects, call RRSolver::setDynamicObjects(). It is cheap call, you can add/remove dynamic objects frequently. Once your dynamic objects are added, you can manipulate them freely.
- Call RRSolver::allocateBuffersForRealtimeGI().
- Set lights, call RRSolver::setLights() with set of lights participating in calculation. Optionally call also RRSolver::setEnvironment() to add outdoor/sky lighting. These calls are cheap, you can change lights frequently.
- Call RRSolver::calculate() often. If main loop of your application contains rendering of one frame, add one call to RRSolver::calculate(). If you render scene only when it has changed, still call RRSolver::calculate() in every iteration of the main loop and if it returns IMPROVED, rerender scene.
- If you use custom/external renderer:
When RRSolver::getSolutionVersion() changes, call RRSolver::updateLightmaps() and RRSolver::updateEnvironmentMap() to update illumination values stored in your buffers.
- Call RRSolver::reportDirectIlluminationChange() whenever direct illumination changes. It is mainly when light moves or changes properties, but for higher precision, you may call it also when object moves and its shadow changes.
- Call RRSolver::reportMaterialChange() whenever materials in static scene change. Right now, this is as expensive as full setStaticObjects() call, but it may be cheap in future.
- Call RRSolver::reportInteraction() whenever user interacts or other reason for high responsiveness exists. Without reportInteraction calls, solver takes more CPU time and FPS decreases.
- Call RRSolver::updateEnvironmentMap() to acquire static or dynamic object's illumination, see Environment map.
Samples like Lightmaps or RealtimeLights show these calls in action.