This is the documentation for Enlighten.

Providing input lighting


Lighting is provided in two stages; direct input lighting and indirect input lighting. The direct input lighting stage computes the surface lighting from all the provided lights, and the indirect input lighting stage applies bounce, albedo and temporal coherence calculations to the results of the direct input lighting stage. The result is an InputLightingBuffer.

Direct input lighting

The indirect input lighting stage takes as input an unsorted array of light pointers, an array of visibility pointers to match the array of lights, a valid input workspace, a transform (useful to move an independent system in world space), and a valid IncidentLightingBuffer which will be used as output.

Creating an IncidentLightingBuffer
Geo::u32 incidentLightingBufferSize = CalcIncidentLightingBufferSize(m_InputWorkspace);
	void* incidentLightingMemory = GEO_ALIGNED_MALLOC(incidentLightingBufferSize, 16);
	IncidentLightingBuffer* incidentLightingBuffer = CreateIncidentLightingBuffer(incidentLightingMemory, m_InputWorkspace);
	m_LightBankBuffers.Push(incidentLightingBuffer);

Call the following function to calculate the direct lighting for a set of lights:

Direct Input Lighting example
Enlighten::DirectInputLightingParameters params;
					params.m_InputWorkspace					= system->GetInputWorkspace();
					params.m_NumLights						= m_TotalNumLights;
					params.m_InputLights					= lightsArray;
					params.m_Transform						= NULL;
					params.m_IncidentLightingBufferResult	= system->GetLightBankBuffer(bankIter->first);
					params.m_ThreadVisibilityPointers		= wtd->m_ThreadVisibilityPointers;

					// write the list of visibility pointers
					WriteVisibilityPointers(wtd->m_ThreadVisibilityPointers, system, bankIter->first);

Geo::u32 timeUs = 0;
					DoDirectInputLighting(&params, wtd->m_WorkingMemory, scrathSpaceSize, timeUs);

Indirect input lighting

Call the following function to calculate the indirect lighting from a set of incident lighting buffers:

Indirect Input Lighting example
Enlighten::IndirectInputLightingParameters params;

			IncidentLightingBuffer* incidentLightingBuffer = cpuDynamicObject->GetIncidentLightingBuffer();
			params.m_IncidentLightingBuffers			= &incidentLightingBuffer;
			params.m_NumIncidentInputLightingBuffers	= 1;
			params.m_EmissiveTextureData				= NULL;
			params.m_AlbedoTextureData					= NULL;
			params.m_EmissiveScale						= Geo::VZero();
			params.m_BounceData							= NULL;
			params.m_BounceScale						= Geo::VBroadcast(m_GlobalState.m_BounceScale);
			params.m_InputWorkspace						= dynamicObject->m_InputWorkspace;
			params.m_ClusterAlbedoWorkspace				= dynamicObject->m_ClusterAlbedoWorkspace;
			params.m_InputLightingBufferResult			= dynamicObject->m_InputLightingBuffer;
			params.m_InputLightingSurroundings			= dynamicObject->m_InputLightingSurroundings;

			Geo::u32 timeUs=0;
			DoIndirectInputLighting(&params, timeUs);

Custom input lighting

If you compute your own input lighting, perhaps on the GPU, provide an incident lighting buffer from a set of duster values with the following function:

bool GEO_CALL		AddDusterValuesToInputWorkspace(const InputWorkspace* workspaceMemory, Enlighten::IncidentLightingBuffer* output, const Geo::v128* dusterValues);