This function converts energy values to volume values, i.e. `occlusionEnergy` is in the range `0.0` to `occlusionRayCount` and must be mapped to a value between `0.0` and `1.0`.
This function runs twice: once for LF energy and once for HF energy. The values it returns controls the gainLF and gainHF properties on a voice's low-pass filter.
The default formula specifies that 15% of energy is required for a voice to be at max volume:
```cs
var formula = (int voiceType, float occlusionEnergy, float permeationEnergy) =>
{
float totalEnergy = 0.0f;
// 15% of energy is considered enough for the voice to be at full volume
if (OcclusionEnabled)
{
float rayThreshold = 0.15f * occlusionRayCount;
totalEnergy += occlusionEnergy / rayThreshold;
}
if (PermeationEnabled)
{
float rayThreshold = 0.15f * permeationRayCount;
totalEnergy += permeationEnergy / rayThreshold;
}
return MathF.Min(1, totalEnergy);
};
```
You can set this value when creating a raytracing context, or update it at run time:
- [[Creating a Raytracing Context#voiceEnergyFormula]]
- [[Updating Raytracing Settings]]