This is the documentation for Enlighten.

Static destruction

By designating geometry as transparent, you can adjust the transparency of the surface at runtime. This is not a physically-based transparency, but rather can be used to emulate destruction of surfaces, either by authoring the destruction or implementing it as a response to gameplay effects.

For transparency to work, Enlighten needs to generate some additional data during precompute. This will happen by default, if however you do not need run time transparency to work for a given system you can switch it off with the following paramset parameter:

computeClusterProbeSampleOffsetData="false"

Once the precompute is run with this flag enabled, an optional RadDataBlock is generated within the InputWorkspace object:

class InputWorkspace
{
public:
...
/// Optional precomputed data used for transparency
RadDataBlock m_ClusterProbeSampleOffsetData;
};

When this data is present in the InputWorkspace object, the following functions can be used to create the runtime transparency workspace:

Geo::u32 GEO_CALL CalcTransparencyWorkspaceSize(const Enlighten::InputWorkspace* inputWorkspace, Geo::s32 numInterpolants, PrecisionHint::Value precision = PrecisionHint::DEFAULT_PRECISION);
Enlighten::TransparencyWorkspace* GEO_CALL CreateTransparencyWorkspace(void* memory, const Enlighten::InputWorkspace* inputWorkspace, Geo::s32 numInterpolants, PrecisionHint::Value precision=PrecisionHint::DEFAULT_PRECISION);

Note: Although the API currently provides specification of the precision, it is currently ignored.

The transparency works by creating sample points on the opposite side of the transparent surface. The distance that these sample points are placed from the surface needs to be the approximate thickness of the transparent wall or object. This offset is automatically generated during the CreateSystemDusters stage of the precompute pipeline.

To modify the transparency of a surface at runtime, update the TransparencyBuffer. You can also specify transparency per-pixel with InitialiseTransparencyBufferFromTexture, per-sample with InitialiseTransparencyBufferFromColoursPerPoint.

Once per frame, before the call to DoIndirectInputLighting(), the transparency workspace needs to be updated with any new values in the probesets. This is done by calling:

void GEO_CALL UpdateTransparencyWorkspace( const InputWorkspace* inputWorkspace, Enlighten::TransparencyWorkspace *transparencyWorkspace, const InterpolationInputSet* interpolationInputs, Geo::s32 numInterpolationInputs, bool recomputeInterpolants);

When a probe set is added or removed from the list of inputs, the UpdateTransparencyWorkspace() function must be called with recomputeInterpolants set to true. If however, only the lighting has changed, then recomputeInterpolants can be set to false.

To reset the transparency and offsets of the workspace, call the following functions passing 0.f for transparencyValue and offset:

bool GEO_CALL SetTransparency(const Enlighten::InputWorkspace* inputWorkspace, Enlighten::TransparencyWorkspace *transparencyWorkspace, float transparencyValue);
bool GEO_CALL SetSamplePositions( const Enlighten::InputWorkspace* inputWorkspace, Enlighten::TransparencyWorkspace *transparencyWorkspace, float offset, bool forceUpdate );

For details on these functions, see InputWorkspace.h.

The transparency workspace must then be set as a parameter on the Enlighten::IndirectInputLightingParameters class.

Sample code for updating the transparency workspace:

//Update transparency workspace
if (system->m_TransparencyWorkspace && m_InterpolationInputSets.GetSize() && lightInputsChanged)
{
Enlighten::UpdateTransparencyWorkspace( system->m_InputWorkspace,
system->m_TransparencyWorkspace,
m_InterpolationInputSets.GetArray(),
m_InterpolationInputSets.GetSize(),
system->m_TransparencyInterpolantsNeedUpdate || requiresProbeInterpolationUpdate);
system->m_TransparencyInterpolantsNeedUpdate = false;
}