This function converts raytracing energy values to filter gain values. > Since multiple emitters can cast rays towards an emitter, we will use the terms '**source**' and '**target**' emitters. The target emitter is the one that is discovered by another emitter, and a source emitter is the one that is casting the rays. The `GainFormula` is invoked twice per source emitter - Once with low-frequency energy values - Once with high-frequency energy values The results of these functions are stored directly on the emitter's filter and accessed via `sourceEmitter.GetTargetFilter(targetEmitter))`. The default formula specifies that 15% of occlusion energy or 50% of permeation energy is required for an emitter to be at max gain: ```cs targetEmitter.GainFormula = (int type, int occlusionRayCount, int permeationRayCount, float occlusionEnergy, float permeationEnergy) => { float totalEnergy = 0.0f; // 15% of energy is considered enough for the emitter to be at full volume if (occlusionRayCount > 0) { float rayThreshold = 0.15f * occlusionRayCount; totalEnergy += occlusionEnergy / rayThreshold; } if (permeationRayCount > 0) { float rayThreshold = 0.5f * permeationRayCount; totalEnergy += permeationEnergy / rayThreshold; } return MathF.Min(1, totalEnergy); } ``` Parameters: - `type` is the `emitter.Type` field, which you can set to anything you like to identify each emitter - `occlusionRayCount` is the number of occlusion rays that were cast by the source emitter - `permeationRayCount` is the number of permeation rays that were cast by the source emitter - `occlusionEnergy` is in the range 0.0 to 1.0, where 1.0 means all occlusion rays discovered the target emitter with maximum energy remaining (i.e. no occlusion) - `permeationEnergy` is in the range 0.0 to 1.0, where 1.0 means all permeation rays discovered the target emitter with maximum energy remaining (i.e. all rays passed through air)