This is the documentation for Enlighten.
Resampling bounce
Overview
Once the lightmap radiosity solver has run, the runtime requires that the solve output data be transformed into a format fit for feeding back into the Indirect Input Lighting stage which expects the bounce to be in the Enlighten::BounceBuffer
object.
The probe radiosity solver outputs directly to the bounce buffer, and further resampling is not required.
Resample bounce
Lightmap bounce resampling
if (system->m_RadSystemCore) { // Create the parameters struct. ResampleBounceParameters bounceParams; // Assign the pointer to the BounceBuffer we wish to update. bounceParams.m_BounceBuffer = system->m_BounceBuffer; // Set the pointer to the systems rad core. bounceParams.m_RadSystemCore = system->m_RadSystemCore; // Set the pointer to the persistent data buffer. This is used for temporal coherence optimisations when quality is set to 0.0f. bounceParams.m_PersistentData = system->m_PresistentDataBuffer; // Create the struct for the texture sampling parameters. ResampleTextureParameters hqBounce; // Set the pointer to the beginning of the texture pixels. hqBounce.m_TextureData = system->GetOutputPointer(ENLIGHTEN_OUTPUT_IRRADIANCE); // Set the width of the texture in pixels. hqBounce.m_TextureWidth = system->m_RadSystemCore->m_MetaData.m_OutputWidth; // Set the height of the texture in pixels. hqBounce.m_TextureHeight = system->m_RadSystemCore->m_MetaData.m_OutputHeight; // Set the row pitch in bytes. hqBounce.m_TexturePitch = system->GetOutputPitchInBytes(ENLIGHTEN_OUTPUT_IRRADIANCE); // Set the byte order of the pixel format. hqBounce.m_ByteOrder = m_OutputFormatByteOrder; hqBounce.m_TextureFormat = system->m_OutputFormat; // Set the rescale factor for fixed point formats. This is the inverse of the maximum representable value. hqBounce.m_FixedPointRescale = IsFixedPointFormat(system->m_OutputFormat) ? m_GlobalState.m_FpFormatRescale : 1.0f; // Set the desired quyality of the bounce resampling. 0.0 is lowest quality (best performance). 1.0 is best quality (lowest performance). hqBounce.m_Quality = m_GlobalState.m_BounceQuality; // Set the parameters. bounceParams.m_ResampleTextureParams = &hqBounce; // Call the function to resample the bounce into the BounceBuffer. Enlighten::ResampleBounce(bounceParams, timeUs); }
2. Set Indirect input lighting parameters
Once the BounceBuffer
has been updated, it should be set as input on the IndirectInputLightingParameters
struct before calling the DoIndirectInputLighting()
function.
Indirect input lighting parameters.
Enlighten::IndirectInputLightingParameters params; //... params.m_BounceBuffer = system->m_BounceBuffer; //...