Emitter Gain Formula

This function converts raytracing energy values to low-pass filter gain values.

The GainFormula is invoked twice per source emitter

The results of these functions are stored directly on the emitter's filter and accessed via listener.GetTargetFilter(target)).

The default formula specifies that 15% of occlusion energy or 15% of permeation energy is required for an emitter to be at max volume:

target.GainFormula = (bool lowFrequency, int occlusionRayCount, int permeationRayCount, int permeationBounceCount, float occlusionEnergy, float permeationEnergy) =>
{
    float gain = 0.0f;

    // 15% of energy is considered enough for the emitter to be at full volume
    if (occlusionRayCount > 0)
    {
        float rayThreshold = 0.15f * occlusionRayCount;
        gain += occlusionEnergy / rayThreshold;
    }

    if (permeationRayCount > 0)
    {
        float rayThreshold = 0.15f * permeationRayCount * permeationBounceCount;
        gain += permeationEnergy / rayThreshold;
    }

    return MathF.Min(1, gain);
}

Parameters: