This is the documentation for Enlighten.

Persistent radiosity data


The precompute outputs radiosity data grouped by system, probe set and cubemap.

The radiosity data for each system is further broken down into objects and sections that enable different functionality in the runtime.

Extract radiosity data

The examples below show how to extract the radiosity data.

To minimize runtime memory usage and loading times, the examples below specify the default sections to include only the data required to enable the core Enlighten runtime functionality.

For most implementations, we recommend to use the precompute pipeline API both to run the precompute and to load these objects.

 To extract the radiosity data for a system:

// path: "radiosity/[system name].rc.sse"
const Enlighten::RadSystemCore* radiosityCore
	= Enlighten::ReadRadSystemCoreFromFile(path, Enlighten::Iff::RadSystemCoreDefaultSections);

// path: "radiosity/[system name].iw.sse"
const Enlighten::InputWorkspace* inputWorkspace
	= Enlighten::ReadInputWorkspaceFromFile(path, Enlighten::Iff::InputWorkspaceDefaultSections);

// path: "radiosity/[system name].vis"
const Enlighten::PrecomputedVisibilityData* directionalVisibility
	= Enlighten::ReadPrecomputedVisibilityDataFromFile(path);

// path: "radiosity/[system name].rnt"
Geo::GeoRGBXTexture* radiosityNormals = LoadInterface<Geo::GeoRGBXTexture>(path);

If the instances within this system are lit using probes, the system does not have lightmap UV data.

For such a system, the radiosity core and radiosity normals are not required.

To extract the radiosity data for a probe set:

// path: radiosity/[probe set name].ps.sse
const Enlighten::RadProbeSetCore* radiosityCore
	= Enlighten::ReadRadProbeSetCoreFromFile(path, Enlighten::Iff::RadProbeSetCoreDefaultSections);

To extract the radiosity data for a cubemap:

// path: radiosity/[cubemap name].rcm.sse
const Enlighten::RadCubeMapCore* radiosityCore
	= Enlighten::ReadRadCubeMapCoreFromFile(path);

Persistent radiosity data

To make it easier to manage the data on disk, we recommend to combine the radiosity data into fewer files. A typical implementation might concatenate all data for the same zone into a single file.

When the radiosity data is loaded on a constrained target platform such as console or mobile device, the memory usage and loading time are critically important. To minimize loading times, store each persistent radiosity data object as a flat buffer. No memory allocation is required when loading the data.

The examples below show how to write radiosity data as a flat buffer to a stream of type IGeoStream. Use GeoFileStream to write to a file, or GeoMemoryStream to write to a buffer.

To write the radiosity data for a system:

Geo::u64 radiosityCoreOffset = stream.GetPosition();
Enlighten::WriteRadSystemCoreForInPlace(radiosityCore, stream);
Geo::u64 radiosityCoreSize = stream.GetPosition() - radiosityCoreOffset;

Geo::u64 inputWorkspaceOffset = stream.GetPosition();
Enlighten::WriteInputWorkspaceForInPlace(inputWorkspace, stream);
Geo::u64 inputWorkspaceSize = stream.GetPosition() - inputWorkspaceOffset;

Geo::u64 directionalVisibility = stream.GetPosition();
Enlighten::WritePrecomputedVisibilityDataForInPlace(directionalVisibility, stream);
Geo::u64 directionalVisibilitySize = stream.GetPosition() - directionalVisibilityOffset;

Geo::u64 radiosityNormalsOffset = stream.GetPosition();
stream.Write(radiosityNormals->GetTextureData(), radiosityNormals->GetTextureData() + radiosityNormals->GetWidth() * radiosityNormals->GetHeight());
Geo::u64 radiosityNormalsCount = radiosityNormals->GetWidth() * radiosityNormals->GetHeight();

To write the radiosity data for a probe set:

Geo::u64 radiosityCoreOffset = stream.GetPosition();
Enlighten::WriteRadProbeSetCoreForInPlace(radiosityCore, stream);
Geo::u64 radiosityCoreSize = stream.GetPosition() - radiosityCoreOffset;

To write the radiosity data for a cubemap:

Geo::u64 radiosityCoreOffset = stream.GetPosition();
Enlighten::WriteRadCubeMapCoreForInPlace(radiosityCore, stream);
Geo::u64 radiosityCoreSize = stream.GetPosition() - radiosityCoreOffset;

Load radiosity data

The examples below show how to load the radiosity data from an array of bytes.

Enlighten::RadSystemCore* radiosityCore = Enlighten::ReadRadSystemCoreInPlace(data + radiosityCoreOffset, radiosityCoreSize);
Enlighten::InputWorkspace* inputWorkspace = Enlighten::ReadInputWorkspaceInPlace(data + inputWorkspaceOffset, inputWorkspaceSize);
Enlighten::PrecomputedVisibilityData* directionalVisibility = Enlighten::ReadPrecomputedVisibilityDataInPlace(data + directionalVisibilityOffset, directionalVisibilitySize);
Geo::GeoRGBXTextureElement* radiosityNormals = reinterpret_cast<Geo::GeoRGBXTextureElement*>(data + radiosityNormalsOffset);
Enlighten::RadProbeSetCore* radiosityCore = Enlighten::ReadRadProbeSetCoreInPlace(data + radiosityCoreOffset, radiosityCoreSize);
Enlighten::RadCubeMapCore* radiosityCore = Enlighten::ReadRadCubeMapCoreInPlace(data + radiosityCoreOffset, radiosityCoreSize);

The radiosity data objects are constructed in-place within the data array. You must allocate the data array with 16-byte alignment.

You must ensure that the data array is not freed while radiosity data is in use. You must not delete or destroy the radiosity data objects directly.