This is the documentation for Enlighten.

Multiple systems at runtime


Overview

The example code in the Low level runtime walkthrough assumes a scene with a single system. If there are multiple systems in a scene, the situation is more complicated because light can now transfer between systems.

Reading from multiple input lighting buffers

To account for the light transfer between systems, all of the relevant input lighting buffers are passed to each instantiation of a solver function (for example SolveIrradianceTask).

Internally, each system knows via its precomputed data which other systems to read from, and matches up the inputs using system GUIDs. This is a two stage process:

  1. First, you must call the helper function Enlighten::PrepareInputLightingList to create a correctly ordered list from an unsorted list of input lighting buffers.
  2. This list can then be passed to the solver function via the task structure. Note that the list could also be cached for use over several frames/solves. It does not matter if too many input lighting buffers are passed to Enlighten::PrepareInputLightingList - it silently ignores any it does not need to read from. The function also succeeds if there is a system missing; however, no light is transferred from missing systems, which may produce odd results. SolveIrradianceTask only fails with an error if the input buffer for the system it is trying to compute output for is missing.

Updating multiple systems

You must ensure that all of the required input lighting has been generated before starting to run any of the radiosity tasks.

To put it another way, the pseudo-code for updating multiple systems should look like this:

The three loops can be individually parallelised, but the first loop must be complete before the others start - the solvers read input lighting from all of the systems.

Multi-threading

With a little bit of care, the Enlighten runtime can be parallelised very successfully. The key pitfall to avoid is updating input lighting for a system while it is being read by a Solve function. The simplest strategy for achieving this is to completely separate input lighting updates from solving updates, as in the pseudo-code above.

GeoRadiosity has a multi-threaded PC runtime. Enlighten uses Intel Threaded Building Blocks to run input lighting for several systems in parallel; afterwards, it runs radiosity solves for several systems in parallel. While all the threads are busy, the performance scales extemely well with the number of processors. Because the systems define the units of work, the best performance is achieved when the systems are all roughly the same size (and there are enough systems to occupy all of the available threads).