This is the documentation for Enlighten.
Albedo and emissive textures
You can generate albedo and emissive textures as an alternative way to provide static albedo and emissive data for surfaces that receive indirect lighting from a lightmap.
This method takes into account the albedo and emissive colours of detail meshes that share the lightmap. The implementation is very similar to the sample point method and produces similar results.
Generate textures
Use the persistent runtime data to create albedo and emissive data for each radiosity system:
- Call GetTextureSize to find the size of the final albedo and emissive textures for the system.
- Create albedo and emissive textures for the system and bind them as multiple render targets in your renderer.
- For each instance in the system, draw the mesh using your materials with a special vertex and pixel shader
- The vertex shader outputs the Enlighten lightmap UV coordinate
- The pixel shader outputs albedo and emissive colours to the render target
- Read back the albedo and emissive textures to CPU accessible memory.
- Call InitialiseAlbedoBufferFromTexture and InitialiseEmissiveBufferFromTexture with the albedo and emissive textures.
We recommend to use TextureResolutionScale::Full to make these textures match the dimensions of the lightmap for the system. If you use a different scale, use GetTextureSize to compute the size of the textures
Check the documentation carefully to make sure you provide colours in the colour spaces expected by InitialiseAlbedoBufferFromTexture and InitialiseEmissiveBufferFromTexture.
To convert from linear colour space to the gamma 2 colour space take the square root of the linear colour space values.
Anti aliasing
The Enlighten lightmap has an extremely low texel resolution when compared to the size of individual mesh triangles or material texels. To render a mesh directly to a texture with the lightmap resolution would cause some obvious aliasing artifacts.
To avoid this we recommend to render to a higher resolution buffer and downsample to the lightmap resolution. We recommend to use render to a buffer with at least four times the lightmap texture resolution.
Detail meshes
To include the albedo and emissive colours of detail meshes, include the detail meshes that project onto instances in the system when you generate the albedo and emissive textures.
We recommend to render all of the detail meshes into the textures after you render all instances in the system. This is a simple approach which usually produces good enough results.