This is the documentation for Enlighten.
Directionality and baking
In order to support view-dependent effects such as specular reflections, Enlighten supports directionality in the baking API. You can use three different methods:
- Directional light maps — As well as obtaining direct and indirect lighting for a given pixel from the normal direction dictated by the underlying geometry, you can specify other lighting normals in order to model off-axis surface geometry generated by, for example, normal maps. For each such additional lighting normal, Enlighten shades a direct and an indirect lightmap. This allows you to specify multiple arbitrary directions, enabling you to use methods such as the Half-Life 2 basis (PDF link).
- Baked directional irradiance — Enlighten also generates an additional texture that stores the dominant light direction in the same way as offered by the directional irradiance method at run-time. For baking, this texture is computed for both indirect and direct lighting.
- Intensity output textures — Instead of storing irradiance in the output light maps, Enlighten can also the intensity of a light in the direction of the dominant light. Used together with the directional light texture, this enables relighting using any possible BRDF. This can be enable by calling the
SetOutputIsIntensity()
method inIBakeInputProperties
or settingoutputIsIntensity
in the bake parameters when using the HLBS.
If only a low-frequency normal texture and no specularity is used, then baking the result of the normal map into the light map is an option with no runtime costs. Enlighten will only bake light maps if enabled in the materials file by setting the useForBaking
attribute of the normal texture to true
. For the low-level API, the normal texture is used if it is set on the material passed into the Enlighten::IBakeInputSystem::AddGeometry
.
Directional light maps
Directional lightmaps (lightmaps using other lighting normals like the Half-Life 2 basis) are widely used and supported by other baking solutions and game engines. As such, this method should work well as a drop-in replacement.
Low level precompute API
To supply the extra lighting normals, an Enlighten::IBakeInputGeometryLightingNormals
object is supplied to Enlighten::IBakeInputSystem::AddGeometry
. The object contains a lighting normal object Enlighten::IBakeInputMeshLightingNormals
for each mesh in the geometry.
Half-Life 2 basis
In order to model any arbitrary surface in three dimensions according to the discussion above, a minimum of three vectors is required per pixel. By selecting three mutually orthonormal vectors you obtain a minimum basis set; that is, a maximally-efficient set of directions using this minimum number of vectors (see http://www2.ati.com/developer/gdc/D3DTutorial10_Half-Life2_Shading.pdf, page 10). If you specify more directions, you can obtain greater fidelity for off-axis geometry; however, if you use the High Level Build System, the Half-Life 2 basis is enforced.
HLBS
When the enableDirectionality
attribute has been set, the High Level Build System automatically uses the normal and tangents stored with the geometry to create a Half-Life 2 basis for each of the vertices. The HLBS creates four baked outputs for each of the direct and indirect lighting cases; one for the normal direction and one for each of the three Half-Life 2 vectors in the basis.
Baked directional irradiance
Storing the dominant lighting direction in addition to the irradiance lightmap is a more memory effective solution then the directional light maps. It also permits seamlessly switching between the runtime and baked solution. On the other hand, baked directional irradiance isn't as effective as directional light maps at modelling light from different directions with different colours.
Low level precompute API
The directional irradiance texture can be retrieved from the Enlighten::IBakeOutputSystemIndirect
and Enlighten::IBakeOutputSystemDirect
objects using the Enlighten::IBakeOutputSystemIndirect::GetDirectionalIrradianceTexture
and Enlighten::IBakeOutputSystemDirect::GetDirectionalIrradianceTexture
methods.
HLBS
The extra directional information is always generated and is output in the same place as the irradiance textures. The texture filename consists of the lightmap name, plus a _Dir
suffix.