This is the documentation for Enlighten.
Baking light masks
As part of baking light maps, Enlighten can also generate light masks. A light mask stores the visibility information per light and per pixel, using the same UVs and assignment of meshes. At runtime, the visibility can be used as part of the shading evaluation. There are several benefits of storing just the visibility. Visibility typically changes at a lower frequency than (for example) the shading normal, and so this reduces memory consumption. Storing visibility instead of irradiance also allows straightforward support for specular materials.
Each pixel in the light mask stores values for the R, G and B colour components separately to support transparent (and coloured) surfaces. Multiply the visible tuple component-wise with the light intensity tuple to get the light that reaches the surface point.
Enlighten can produce light masks without any additional baking costs, but you need to tag the light used in baking for which light masks need to be generated. Separately, the direct light contribution of a light in light maps can be disabled. The light will still influence indirect lighting. This allows you to only use light masks for a selected subset of lights and fully bake the rest of the lights.
As an example, the following pictures show the Cornell Box scene lit by two white spotlights; one pointing at the red wall, and one pointing at the green wall.
The next pictures show different outputs of the Enlighten baking. The left picture shows the composited light map; it contains direct and indirect light as well as ambient occlusion. The middle picture contains only the direct light. Both clearly show the direct light of both spotlights. The right picture shows the light mask generated for the right spotlight. In addition to only showing the right spotlight, note that the visible gradients of the spotlights in the middle picture are not part of the light mask. The light mask only contains the visibility information and doesn't include the angular, the distance or the cosine falloff.
The next two pictures show the effect of disabling the direct lighting for selected lights. The left picture is the same as above, showing the scene with direct lighting enabled for both spotlights. The right picture has the direct lighting disabled for the right spotlight. Note that the right light still produces indirect light, visible in the clear green bounce lights.
Generating light masks with the HLBS
In the .lights
configuration file, use the disableDirect
and generateLightMask
boolean attributes to disable direct lighting and enable the generation of a light mask respectively.
For each light and for each light map, the baking output folder will contain a output file named Visibility_<light name>_<light map>_<light type>.tex
. Using the same file format as the other baked output files, the visibility is stored in a floating point format. You can either use the supplied serialisation methods to load and convert the image into the format of your choice, or use GeoConvert
with the /ConvertTexToExr
command to convert the image into the standard EXR image format.
Generating light masks with the low-level API
The BakeInputLight
structure contains the m_DisableDirect
and m_GenerateLightMask
boolean attributes. For lights with m_GenerateLightMask
set to true
, the light mask can be retrieved using the IBake::BakeSystemVisibility()
method after the IBakeVisibilityBuffer
has been updated (or created).