This is the documentation for Enlighten.
module Input Lighting
Operations relating to input lighting generation for the Enlighten runtime.
This is the original input lighting api. Note that there is a new 'extended' input lighting api available on most platforms through EnlightenInputLighting.h.
There is a considerable amount of freedom in how you choose to provide input lighting to Enlighten and the design trade-offs involved can have a huge impact on the success of Enlighten in your product. Most games are unique in some respect, so please feel free to contact Enlighten support for help in choosing the best option for your game.
There are also now two apis for providing input lighting to Enlighten. This one (the original api) and a newer 'extended' input lighting api, available through EnlightenInputLighting.h. They both use the same InputWorkspace structure and have other elements in common, but differ in how the calculation is performed, and the extended api supports additional features.
Enlighten uses a physically realistic algorithm for bouncing indirect light around a scene (subject to the tweakable albedo and bounce scale values), but makes no particular assumptions about the direct lighting model.
In practice, it's often more convenient to use a non-physical fall-off model for spot and point lights. They can be simpler to work with, reduce artefacts, and given the limitations of output displays it's often the only way to produce the desired effect.
Because of this, Enlighten allows users to specify a custom distance fall-off for point and spot light using the Enlighten::InputLightFalloffTable. Now, it is worth emphasising that there needn't be an exact correspondence between the model used for direct, on-screen lighting and the model used for producing input lighting for Enlighten. The closer the two models correspond, the more self-consistent the lighting model as a whole; on the other hand, if the Enlighten input lighting uses a completely non-physical model, it can produce counter-intuitive effects. (One example would be that the amount of light in the scene could vary wildly as a light source of constant intensity is moved closer to or further away from geometry; as soon as the model is non-physical, energy is not necessarily conserved.)
For convenience, Enlighten provides two API functions for generating suitable fall-off tables: Enlighten::GenerateUnrealCompatibleLightFalloffTable(), Enlighten::GenerateUnityCompatibleLightFalloffTable() and Enlighten::GenerateInverseSquaredLightFalloffTable(). See also the Enlighten::InputLight class.
Classes
Name | Description |
|---|---|
A base class all light types must derive from to work with any input lighting API. | |
Class encapsulating the description of a light falloff curve. | |
A single frame of the InputWorkspace lighting (internal). | |
A structure for receiving the data held internally about a duster point for debugging visualisation purposes. | |
Runtime data storing precomputed visibility information (eg, for directional lights) | |
Runtime data allocated by end user that stores uncompressed precomputed visibility data. | |
Supported formats for visibility data. |
Variables
Name | Description |
|---|---|
void *const LIGHT_VISIBILITY_DISABLED = (void*)1 | Equivalent to light visibility data with all bits set to 0. |
Functions
Name | Description |
|---|---|
Adds light values from one input lighting buffer to another. | |
AddDusterValuesToInputWorkspace(const InputWorkspace *, InputLightingBuffer *, const Geo::v128 *) | Adds light values laid out in a duster block to an Enlighten input workspace. |
CalcInputLightingBufferSize(const InputWorkspace *, PrecisionHint::Value) | Tells you the amount of memory required to hold input lighting for a given system. |
Determine how much memory is required for a light visibility block. | |
CalcLightVisibilitySize(const InputWorkspace *, Enlighten::VisibilityFormat::Type) | Determine how much memory is required for a light visibility block. |
CalcPrecomputedVisibilityWorkspaceSize(const InputWorkspace *, const PrecomputedVisibilityData *) | Determine how much memory is required for a precomputed visibility workspace. |
ClearInputWorkspace(const InputWorkspace *, InputLightingBuffer *) | Clear the input lighting to black. |
Compares Returns true if the lighting buffers could be compared. | |
CreateInputLightingBuffer(void *, const InputWorkspace *, PrecisionHint::Value) | Construct an InputLightingBuffer inside the memory provided. |
Construct an PrecomputedVisibilityWorkspace inside the memory provided. | |
GenerateInverseSquaredLightFalloffTable(InputLightFalloffTable *, float, float) | Helper function that generates a Falloff Table using an inverse squared light falloff function, closely approximating real world light falloff. |
GenerateUnityCompatibleLightFalloffTable(InputLightFalloffTable *) | Helper function that generates a falloff table compatible with the Unity light falloff model. |
GenerateUnrealCompatibleLightFalloffTable(InputLightFalloffTable *, float) | Helper function that generates a Falloff Table compatible with the Unreal light falloff model. |
GetInputLightingBufferLightValue(const InputLightingBuffer *, float, Geo::s32) | Fill the specified array with the current light value for the given cluster index. |
Returns the size of the specified InputLightingBuffer object. | |
GetInputLightingBufferSystemId(const Enlighten::InputLightingBuffer *) | Get system id from InputLightingBuffer. |
GetInputWorkspaceDebugIterator(const InputWorkspace *, Enlighten::InputWorkspaceDebugIterator &) | Return a debug iterator object in {debugIterator} which can be used to iterate through the systems debug points. |
GetInputWorkspaceDebugPoint(const InputWorkspace *, InputWorkspaceDebugPoint *, Geo::s32) | Fill the specified debug data structure with the current values for the given input workspace sample point. |
Fill the specified debug data structure with the current values for the given input workspace sample point. | |
GetInputWorkspaceNormalArray(const InputWorkspace *, Geo::v128 *) | Fills an array with the normals of all of the input points in an input workspace. |
GetInputWorkspaceNumPointsPerClusterArray(const InputWorkspace *, Geo::s32 *) | Fills the array with the number of points per cluster. |
GetInputWorkspacePositionAndNormalArray(const InputWorkspace *, Geo::v128 *, Geo::v128 *) | Fills arrays with the positions and normals of all of the input points in an input workspace. |
GetInputWorkspacePositionArray(const InputWorkspace *, Geo::v128 *) | Fills an array with the positions of all of the input points in an input workspace. |
Returns the size of the specified InputWorkspace object. | |
Returns the total number of clusters in an input workspace. | |
Returns the total number of output buckets. | |
Returns the total number of output pixels being lit. | |
GetNumberOfOutputPixelsInBucket(const RadSystemCore *, const Geo::s32 &) | Returns the total number of output pixels in the given bucket. |
Returns the total number of sample duster points in an input workspace. | |
GetNumberOfTreeClustersInInputWorkspace(const InputWorkspace *) | Returns the total number of tree clusters in an input workspace. |
GetPrecomputedVisibilityDataSize(const PrecomputedVisibilityData *) | Returns the size of the specified PrecomputedVisibilityData object. |
GetSystemBoundingBox(const InputWorkspace *, Geo::GeoBoundingBox &) | Returns the axis-aligned bounding box of the set of input points in the input workspace. |
GetSystemBounds(const InputWorkspace *, Geo::GeoBoundingBox &) | Retrieve the bounding volume of the system. |
Set visibility in an input workspace for a directional light, using precomputed visibility data. | |
Returns true if there are no NaN's or non-finite numbers in the specified InputLightingBuffer object. | |
WriteInputLightingBuffer(const Enlighten::InputLightingBuffer *, Enlighten::InputLightingBuffer *) | Overwrite an InputLightingBuffer with another InputLightingBuffer. |
Enums
Name | Description |
|---|---|
Different types of Enlighten input lights. |
Typedefs
Name | Description |
|---|---|
Geo::s32 LightTypeId | LightTypeIds type. |
bool GEO_CALL Enlighten::AddCachedValuesToInputWorkspace
public: bool GEO_CALL AddCachedValuesToInputWorkspace
(
const InputWorkspace * workspaceMemory,
InputLightingBuffer * output,
const InputLightingBuffer * cachedValues
)
Adds light values from one input lighting buffer to another.
Parameters
[in] | workspaceMemory | The input workspace memory block used in the two buffers. |
[in] | output | The input lighting that is added to. |
[in] | cachedValues | The input lighting to add. |
bool GEO_CALL Enlighten::AddDusterValuesToInputWorkspace
public: bool GEO_CALL AddDusterValuesToInputWorkspace
(
const InputWorkspace * workspaceMemory,
InputLightingBuffer * output,
const Geo::v128 * dusterValues
)
Adds light values laid out in a duster block to an Enlighten input workspace.
Parameters
[in] | workspaceMemory | The input workspace memory block. |
[in] | output | The lighting buffer to fill with data. |
[in] | dusterValues | The linear light colour values for the duster array of point samples. The duster (its size, positions, normals etc.) must match the one originally passed to CreateInputWorkspace. |
Geo::u32 GEO_CALL Enlighten::CalcInputLightingBufferSize
public: Geo::u32GEO_CALL CalcInputLightingBufferSize
(
const InputWorkspace * inputWorkspace,
PrecisionHint::Value precisionHint
)
Tells you the amount of memory required to hold input lighting for a given system.
Parameters
[in] | inputWorkspace | The InputWorkspace for the system. |
[in] | precisionHint | The hint to what floating point precision to use. |
Returns
Required memory in bytes, 0xFFFFFFFF upon error.
Geo::u32 GEO_CALL Enlighten::CalcLightVisibilitySize
public: Geo::u32GEO_CALL CalcLightVisibilitySize
(
const InputWorkspace * workspaceMemory,
eLightType lightType
)
Determine how much memory is required for a light visibility block.
Directional lights store a byte per cluster, all other lights store a bit per input sample (duster).
Parameters
[in] | workspaceMemory | The input workspace memory block. |
[in] | lightType | Type of light; one of the Enlighten light type constants, e.g. LIGHT_TYPE_DIRECTIONAL_LIGHT |
Returns
Required memory in bytes, 0xFFFFFFFF upon error.
Geo::u32 GEO_CALL Enlighten::CalcLightVisibilitySize
public: Geo::u32GEO_CALL CalcLightVisibilitySize
(
const InputWorkspace * workspaceMemory,
Enlighten::VisibilityFormat::Type visibilityType
)
Determine how much memory is required for a light visibility block.
Directional lights store a byte per cluster, all other lights store a bit per input sample (duster).
Parameters
[in] | workspaceMemory | The input workspace memory block. |
[in] | visibilityType | Format of the visibility. Must be one of the types defined in VisibilityFormat |
Returns
Required memory in bytes, 0xFFFFFFFF upon error.
Geo::u32 GEO_CALL Enlighten::CalcPrecomputedVisibilityWorkspaceSize
public: Geo::u32GEO_CALL CalcPrecomputedVisibilityWorkspaceSize
(
const InputWorkspace * workspaceMemory,
const PrecomputedVisibilityData * precomputedVisibilityData
)
Determine how much memory is required for a precomputed visibility workspace.
Parameters
[in] | workspaceMemory | The input workspace memory block. |
[in] | precomputedVisibilityData | The block of precomputed visibilty data. |
Returns
Required memory in bytes, 0xFFFFFFFF upon error.
bool GEO_CALL Enlighten::ClearInputWorkspace
public: bool GEO_CALL ClearInputWorkspace
(
const InputWorkspace * workspaceMemory,
InputLightingBuffer * buffer
)
Clear the input lighting to black.
This wipes out all bounced light for all previous iterations. Used when "starting over".
Parameters
[in] | workspaceMemory | The input workspace this buffer is used in. |
[in] | buffer | The lighting buffer to clear. |
bool GEO_CALL Enlighten::CompareInputLightingBuffers
public: bool GEO_CALL CompareInputLightingBuffers
(
Geo::Statistics & res,
const InputLightingBuffer * bufA,
const InputLightingBuffer * bufB
)
Compares Returns true if the lighting buffers could be compared.
Parameters
[inout] | res | - The result of the comparison. Only written if the function succeeded. |
[in] | bufA | - The first InputLightingBuffer to compare. |
[in] | bufB | - The second InputLightingBuffer to compare. |
InputLightingBuffer* GEO_CALL Enlighten::CreateInputLightingBuffer
public: InputLightingBuffer *GEO_CALL CreateInputLightingBuffer
(
void * memory,
const InputWorkspace * inputWorkspace,
PrecisionHint::Value precisionHint
)
Construct an InputLightingBuffer inside the memory provided.
Parameters
[in] | memory | A block of memory (size determined by CalcInputLightingBufferSize) to store the lighting buffer |
[in] | inputWorkspace | The InputWorkspace for the system. |
[in] | precisionHint | The hint to what floating point precision to use. |
PrecomputedVisibilityWorkspace* GEO_CALL Enlighten::CreatePrecomputedVisibilityWorkspace
public: PrecomputedVisibilityWorkspace *GEO_CALL CreatePrecomputedVisibilityWorkspace
(
void * memory,
const InputWorkspace * workspaceMemory,
const PrecomputedVisibilityData * precomputedVisibilityData
)
Construct an PrecomputedVisibilityWorkspace inside the memory provided.
Parameters
[in] | memory | A block of memory (size determined by CalcPrecomputedVisibilityWorkspaceSize) to store the visibility workspace |
[in] | workspaceMemory | The input workspace memory block. |
[in] | precomputedVisibilityData | The block of precomputed visibilty data. |
bool GEO_CALL Enlighten::GenerateInverseSquaredLightFalloffTable
public: bool GEO_CALL GenerateInverseSquaredLightFalloffTable
(
InputLightFalloffTable * lightTable, float lightFalloffDistance, float lightRadius)