This is the documentation for Enlighten.

Resampling bounce

Overview

Once the 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. This can be done in one of two ways, depending on the source of the bounce.

1. Lightmap 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. Probe bounce

The bounce from probe radiosity systems can be resampled by calling Enlighten::UpdateProbeBounceBuffer().

Probe bounce resampling
if (system->IsBounceProbeSampled() &&
		system->m_ProbeBounceWorkspace &&
		m_InterpolationInputSets.GetSize() > 0)
	{
		if (m_ProbeSetManager != NULL)
		{
			Enlighten::UpdateProbeBounceBuffer(system->m_InputWorkspace,
				system->m_ProbeBounceWorkspace,
				system->m_BounceBuffer,
				m_ProbeSetManager,
				system->m_ProbeBounceInputSetsUsed != m_InterpolationInputSets.GetSize() || requiresProbeInterpolationUpdate);
		}
		else
		{
			Enlighten::UpdateProbeBounceBuffer(system->m_InputWorkspace,
				system->m_ProbeBounceWorkspace,
				system->m_BounceBuffer,
				m_InterpolationInputSets.GetArray(),
				m_InterpolationInputSets.GetSize(),
				system->m_ProbeBounceInputSetsUsed != m_InterpolationInputSets.GetSize() || requiresProbeInterpolationUpdate);
		}

		system->m_ProbeBounceInputSetsUsed = m_InterpolationInputSets.GetSize();
	}

3. Set Indirect input lightintg 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;
//...