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 |
---|---|
Enlighten::InputLightBase | A base class all light types must derive from to work with any input lighting API. |
Enlighten::InputLightFalloffTable | Class encapsulating the description of a light falloff curve. |
Enlighten::InputLightingBuffer | A single frame of the InputWorkspace lighting (internal). |
Enlighten::InputWorkspaceDebugPoint | A structure for receiving the data held internally about a duster point for debugging visualisation purposes. |
Enlighten::PrecomputedVisibilityData | Runtime data storing precomputed visibility information (eg, for directional lights) |
Enlighten::PrecomputedVisibilityWorkspace | Runtime data allocated by end user that stores uncompressed precomputed visibility data. |
Enlighten::VisibilityFormat | 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
Enums
Name | Description |
---|---|
eLightType | 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
)
Helper function that generates a Falloff Table using an inverse squared light falloff function, closely approximating real world light falloff.
Light falloff is smoothly biased to zero as it approaches the cutoff.
Parameters
[out] | lightTable | The Input Light Falloff Table to write to. |
[in] | lightFalloffDistance | The falloff distance the light table will represent, typically (m_Cutoff - m_Radius), must be > 0. |
[in] | lightRadius | The radius of the simulated light source, typically m_Radius or 1.0, must be > 0. |
bool GEO_CALL Enlighten::GenerateUnityCompatibleLightFalloffTable
public: bool GEO_CALL GenerateUnityCompatibleLightFalloffTable
(
InputLightFalloffTable * lightTable
)
Helper function that generates a falloff table compatible with the Unity light falloff model.
Parameters
[out] | lightTable | The input light falloff table to write to. |
bool GEO_CALL Enlighten::GenerateUnrealCompatibleLightFalloffTable
public: bool GEO_CALL GenerateUnrealCompatibleLightFalloffTable
(
InputLightFalloffTable * lightTable,
float falloffExponent
)
Helper function that generates a Falloff Table compatible with the Unreal light falloff model.
Parameters
[out] | lightTable | The Input Light Falloff Table to write to. |
[in] | falloffExponent | The falloff exponent of the light, must be > 0. |
bool GEO_CALL Enlighten::GetInputLightingBufferLightValue
public: bool GEO_CALL GetInputLightingBufferLightValue
(
const InputLightingBuffer * inputLightingBuffer,
float lightValue,
Geo::s32 clusterIdx
)
Fill the specified array with the current light value for the given cluster index.
Geo::u32 GEO_CALL Enlighten::GetInputLightingBufferSize
public: Geo::u32GEO_CALL GetInputLightingBufferSize
(
const InputLightingBuffer * inputLightingBuffer
)
Returns the size of the specified InputLightingBuffer object.
Parameters
[in] | inputLightingBuffer | The InputLightingBuffer to query. |
Returns
Required memory in bytes, 0xFFFFFFFF upon error.
Geo::GeoGuid GEO_CALL Enlighten::GetInputLightingBufferSystemId
public: Geo::GeoGuidGEO_CALL GetInputLightingBufferSystemId
(
const Enlighten::InputLightingBuffer * inputLightingBuffer
)
Get system id from InputLightingBuffer.
Parameters
[in] | inputLightingBuffer | The InputLightingBuffer to query. |
bool GEO_CALL Enlighten::GetInputWorkspaceDebugIterator
public: bool GEO_CALL GetInputWorkspaceDebugIterator
(
const InputWorkspace * inputWorkspace,
Enlighten::InputWorkspaceDebugIterator & debugIterator
)
Return a debug iterator object in {debugIterator} which can be used to iterate through the systems debug points.
bool GEO_CALL Enlighten::GetInputWorkspaceDebugPoint
public: bool GEO_CALL GetInputWorkspaceDebugPoint
(
const InputWorkspace * inputWorkspace,
InputWorkspaceDebugPoint * debugPoint,
Geo::s32 index
)
Fill the specified debug data structure with the current values for the given input workspace sample point.
Does not include lighting.
bool GEO_CALL Enlighten::GetInputWorkspaceLitDebugPoint
public: bool GEO_CALL GetInputWorkspaceLitDebugPoint
(
const InputWorkspace * inputWorkspace,
InputWorkspaceDebugPoint * debugPoint,
Geo::s32 index,
const InputLightingBuffer * lightValues
)
Fill the specified debug data structure with the current values for the given input workspace sample point.
Does not include albedo information, as this is part of the various albedo workspaces.
bool GEO_CALL Enlighten::GetInputWorkspaceNormalArray
public: bool GEO_CALL GetInputWorkspaceNormalArray
(
const InputWorkspace * inputWorkspace,
Geo::v128 * normalsOut
)
Fills an array with the normals of all of the input points in an input workspace.
The array should be big enough to hold one vector for each point in the input workspace. The number of points is returned by GetNumberOfPointsInInputWorkspace().
Parameters
[in] | inputWorkspace | The input workspace to use. |
[out] | normalsOut | Pointer to an array of vectors to write the normals to. |
bool GEO_CALL Enlighten::GetInputWorkspaceNumPointsPerClusterArray
public: bool GEO_CALL GetInputWorkspaceNumPointsPerClusterArray
(
const InputWorkspace * inputWorkspace,
Geo::s32 * numPointsPerClusterArray
)
Fills the array with the number of points per cluster.
The points inside an input workspace are ordered and grouped by cluster, so you can identify which point belongs it which cluster from this information. You can also produce this information from GetInputWorkspaceDebugPoint() and GetInputWorkspaceLitDebugPoint(), but this implementation would be more efficient.
Parameters
[in] | inputWorkspace | A valid input workspace. |
[in] | numPointsPerClusterArray | The array to fill. Must be at least as long as that returned by GetNumberOfClustersInInputWorkspace() |
Returns
False on error, true otherwise.
bool GEO_CALL Enlighten::GetInputWorkspacePositionAndNormalArray
public: bool GEO_CALL GetInputWorkspacePositionAndNormalArray
(
const InputWorkspace * inputWorkspace,
Geo::v128 * positionsOut,
Geo::v128 * normalsOut
)
Fills arrays with the positions and normals of all of the input points in an input workspace.
This array can then be used for visibility computations (eg on the GPU).
Parameters
[in] | inputWorkspace | The input workspace to use. |
[out] | positionsOut | Pointer to an array of vectors to write the positions to. |
[out] | normalsOut | Pointer to an array of vectors to write the normals to. Both arrays should be big enough to hold one vector for each point in the input workspace. The number of points is returned by GetNumberOfPointsInInputWorkspace(). |
See Also
bool GEO_CALL Enlighten::GetInputWorkspacePositionArray
public: bool GEO_CALL GetInputWorkspacePositionArray
(
const InputWorkspace * inputWorkspace,
Geo::v128 * positionsOut
)
Fills an array with the positions of all of the input points in an input workspace.
This array can then be used for visibility computations (eg on the GPU). The array should be big enough to hold one vector for each point in the input workspace. The number of points is returned by GetNumberOfPointsInInputWorkspace().
Parameters
[in] | inputWorkspace | The input workspace to use. |
[out] | positionsOut | Pointer to an array of vectors to write the positions to. |
Geo::u32 GEO_CALL Enlighten::GetInputWorkspaceSize
public: Geo::u32GEO_CALL GetInputWorkspaceSize
(
const InputWorkspace * inputWorkspace
)
Returns the size of the specified InputWorkspace object.
Returns
Memory used in bytes, 0xFFFFFFFF upon error.
Geo::s32 GEO_CALL Enlighten::GetNumberOfClustersInInputWorkspace
public: Geo::s32GEO_CALL GetNumberOfClustersInInputWorkspace
(
const InputWorkspace * inputWorkspace
)
Returns the total number of clusters in an input workspace.
Returns
Number of clusters, -1 upon error.
Geo::s32 GEO_CALL Enlighten::GetNumberOfOutputBuckets
public: Geo::s32GEO_CALL GetNumberOfOutputBuckets
(
const RadSystemCore * radCore
)
Returns the total number of output buckets.
Returns
Number of buckets, -1 upon error.
Geo::s32 GEO_CALL Enlighten::GetNumberOfOutputPixels
public: Geo::s32GEO_CALL GetNumberOfOutputPixels
(
const RadSystemCore * radCore
)
Returns the total number of output pixels being lit.
Returns
Number of pixels, -1 upon error.
Geo::s32 GEO_CALL Enlighten::GetNumberOfOutputPixelsInBucket
public: Geo::s32GEO_CALL GetNumberOfOutputPixelsInBucket
(
const RadSystemCore * radSysCore,
const Geo::s32 & bucketIdx
)
Returns the total number of output pixels in the given bucket.
Returns
Number of pixels in bucket, -1 upon error.
Geo::s32 GEO_CALL Enlighten::GetNumberOfPointsInInputWorkspace
public: Geo::s32GEO_CALL GetNumberOfPointsInInputWorkspace
(
const InputWorkspace * inputWorkspace
)
Returns the total number of sample duster points in an input workspace.
Returns
Number of points, -1 upon error.
Geo::s32 GEO_CALL Enlighten::GetNumberOfTreeClustersInInputWorkspace
public: Geo::s32GEO_CALL GetNumberOfTreeClustersInInputWorkspace
(
const InputWorkspace * inputWorkspace
)
Returns the total number of tree clusters in an input workspace.
Returns
Number of tree clusters, -1 upon error.
Geo::u32 GEO_CALL Enlighten::GetPrecomputedVisibilityDataSize
public: Geo::u32GEO_CALL GetPrecomputedVisibilityDataSize
(
const PrecomputedVisibilityData * visibilityData
)
Returns the size of the specified PrecomputedVisibilityData object.
Returns
Memory used in bytes, 0xFFFFFFFF upon error.
bool GEO_CALL Enlighten::GetSystemBoundingBox
public: bool GEO_CALL GetSystemBoundingBox
(
const InputWorkspace * inputWorkspace,
Geo::GeoBoundingBox & bb
)
Returns the axis-aligned bounding box of the set of input points in the input workspace.
Parameters
[in] | inputWorkspace | The input workspace to compute the bounding box for. |
[out] | bb | The bounding box object to receive the system bounds. |
bool GEO_CALL Enlighten::GetSystemBounds
public: bool GEO_CALL GetSystemBounds
(
const InputWorkspace * inputWorkspace,
Geo::GeoBoundingBox & boundingBox
)
Retrieve the bounding volume of the system.
Parameters
[in] | inputWorkspace | The input workspace for the system |
[out] | boundingBox | The bounding box for the system |
bool GEO_CALL Enlighten::SetDirectionalVisibility
public: bool GEO_CALL SetDirectionalVisibility
(
const InputWorkspace * workspaceMemory,
const PrecomputedVisibilityData * precomputedVisibilityData,
PrecomputedVisibilityWorkspace * visibilityWorkspace,
void * visibilityData,
Geo::v128 lightDirection
)
Set visibility in an input workspace for a directional light, using precomputed visibility data.
Parameters
[in] | workspaceMemory | The input workspace memory block. |
[in] | precomputedVisibilityData | The block of precomputed visibility data. |
[in] | visibilityWorkspace | The visibility workspace memory block. |
[in] | visibilityData | The visibility data to set, one bit per duster. |
[in] | lightDirection | The direction of the light source. |
bool GEO_CALL Enlighten::VerifyInputLightingBufferData
public: bool GEO_CALL VerifyInputLightingBufferData
(
const InputLightingBuffer * inputLightingBuffer
)
Returns true if there are no NaN's or non-finite numbers in the specified InputLightingBuffer object.
Parameters
[in] | inputLightingBuffer | The InputLightingBuffer to query. |
bool GEO_CALL Enlighten::WriteInputLightingBuffer
public: bool GEO_CALL WriteInputLightingBuffer
(
const Enlighten::InputLightingBuffer * source,
Enlighten::InputLightingBuffer * destination
)
Overwrite an InputLightingBuffer with another InputLightingBuffer.
Fails if the system ids or sample counts do not match.
Parameters
[in] | source | - The InputLightingBuffer to read. |
[inout] | destination | - The InputLightingBuffer to write. |
eLightType
public: enum eLightType
{
LIGHT_TYPE_INVALID = -1,
LIGHT_TYPE_SPOT_LIGHT = 0,
LIGHT_TYPE_POINT_LIGHT = 1,
LIGHT_TYPE_DIRECTIONAL_LIGHT = 2,
LIGHT_TYPE_RECTANGLE_LIGHT = 3,
LIGHT_TYPE_FRUSTUM_LIGHT = 4,
LIGHT_TYPE_BOXSPOT_LIGHT = 5,
LIGHT_TYPE_NUM_TYPES
}
Different types of Enlighten input lights.
enumerators
LIGHT_TYPE_INVALID | Invalid light type. |
LIGHT_TYPE_SPOT_LIGHT | Spot light. |
LIGHT_TYPE_POINT_LIGHT | Point light. |
LIGHT_TYPE_DIRECTIONAL_LIGHT | Directional light. |
LIGHT_TYPE_RECTANGLE_LIGHT | Rectangular area light (only available on PC) |
LIGHT_TYPE_FRUSTUM_LIGHT | Frustum light. |
LIGHT_TYPE_BOXSPOT_LIGHT | BoxSpot light. |
LIGHT_TYPE_NUM_TYPES |