This is the documentation for Enlighten.
Baking with the low level bake API
Baked lighting is deprecated and will be removed in a future release.
Overview
This section describes the low level baking API (the EnlightenBake library).
Key
Bake system definition
The initial stage of the baking is:
Decide which Enlighten IPrecompInputGeometry instances you want in each bake system. Each bake system represents one output lightmap.
Create an IBakeInputSystem for each bake system you want. Ensure the name is unique.
Set the resolution of the system in the Enlighten IBakeInputProperties, and if you are not creating your own lightmap UV stream, turn packing on here also. Use
IBakeInputSystem::SetBakePropertiesto pass the properties to the bake system.For each instance in that system, create a Enlighten BakeInputMeshInfo object filling out the fields appropriately, and then call
IBakeInputSystem::AddMesh().Call
IBakeInputSystem::Finalise(), and extract the new lightmap UV stream if packing was required.
Outputs from a previous stage are never modified by a later one, so you can often run these stages in parallel (for example, through distributed build systems such as IncrediBuild).
The diagram below shows the creation of one IBakeInputSystem. Repeat for each output map required.
Direct light baking
First, all the bake systems have to be combined into a BakeSystemResource object. This object is used to create a KD tree for the other stages to trace against, so requires updating if any geometry changes.
Next, copy lighting information into an IBakeInputLighting object.
Now, for each
BakeSystemResource, create an IBakeVisibilityBuffer with theIBakeAPI. This operation is slow; therefore if only the lights have changed (and not the geometry) you can pass in anIBakeVisibilityBufferfrom a previous run and it will be updated.Call
IBake::BakeSystemDirect()to create the IBakeOutputSystemDirect. Optionally pass in a BakeSystemResource object to be able to apply a visibility-aware post-processing filter, with its size set as the filter size baking property. The final output texture, in FP16 format, can be pulled from this object.
The diagrams below show a scene with two IBakeInputSystems; there may be more or fewer than this.
Indirect light baking
Create an IBakeInputRuntime and fill it with the RadSystemCore and InputWorkspace of each Enlighten system.
For each Enlighten system, create an IBakeInputSystem using all the Radiosity objects of the Enlighten system. This is required later in the process in order to fit the Enlighten lit instances to the bake system instances. Set the resolution of the IBakeInputSystem to the resolution of the Enlighten lightmap via an IBakeInputProperties object passed to the
IBakeInputSystem::SetBakePropertiesmethod.For each Enlighten system, call
IBake::CreateRuntimeLightingto create an IBakeRuntimeLighting from:the IBakeInputSystem that you just made
the global IBakeInputLighting
For each runtime lighting you made:
For each bake system representing the output lightmaps:
Call
IBake::UpdateRuntimeLightingto apply the light and albedo information for each bake system to the Enlighten system.
Call
IBake::FinaliseRuntimeLighting
Call
IBake::RunEnlightenSolver; this takes all the information and spins a small Enlighten Runtime until the lighting values settle. This is run only once as it contains information about every system in the bake.For each bake system, call
IBake::BakeSystemIndirectand extract the indirect lighting from the IBakeOutputSystemIndirect it creates. Optionally pass in a BakeSystemResource object and a IBakeInputRayOriginPositions to be able to enable visibility-aware upsampling with the identically named baking property.
Final Gather light baking
Final Gather creates a refined version of the indirect lightmap through ray tracing, by using previously calculated indirect and direct lightmaps. The final gather baking thus has a dependency on all the IBakeOutputSystemIndirect and all the IBakeOutputSystemDirect objects previously created for the baked scene, as well as their matching IBakeInputSystem objects. It also has a dependency on the IBakeSystemResource object (used for raytracing) and the IBakeSolvedRuntime objects for the baked scene.
For each IBakeInputSystem, call
IBake::BakeSystemFinalGather.Extract the FP16 output textures from the resulting IBakeOutputSystemFinalGather objects.
Ambient occlusion
For each BakeSystemResource, call
IBake::BakeSystemAO.Extract the FP16 output textures from the resulting IBakeOutputSystemAO objects.
Direct light baking for probes
First, copy lighting information into an IBakeInputLighting object.
Now, for each probe set represented by an IPrecompInputProbeSet, create an IBakeVisibilityBuffer with the
IBakeAPI. You also need to pass in a BakeSystemResource object, with all the systems that can influence the direct lighting for the probes. This operation is slow; therefore if only the lights have changed (and not the geometry) you can pass in anIBakeVisibilityBufferfrom a previous run and it will be updated.Call
IBake::BakeProbeSetDirect()to create the IBakeOutputProbeSet. Use theIBakeOutputProbeSet::GetOutput()method to retrieve the SH coefficients of all probes in the probe set.
Indirect light baking for probes
First follow the steps described in Indirect light baking.
Now, for each probe in a probe set, use the
IBakeSolvedRuntime::GetSolvedProbe()method of IBakeSolvedRuntime to retrieve the SH coefficients.
Baked Radiosity Normal Texture
The baked radiosity normal texture is needed when using baked directional irradiance to better bring out features when the fine-grained shading normal used in runtime deviates from the cruder normal used for computing radiosity. (typical example is re-lighting normal maps)
For each BakeInputSystem, call
IBake::BakeSystemRadiosityNormal, providing the BakeSolvedRuntime for all Enlighten systems.Extract the FP16 output textures from the resulting IBakeOutputSystemRadiosityNormal objects.
Message reporting and error handling
If you experience problems when using the Low Level Precompute API, call the GeoAttachSystemLoggers/GeoAttachLogger functions to issue error and warning messages. For more information, see the API documentation at module Message Reporting and Error Handling.