| GraphicsHelperGetDistanceAttenuation Method |
Computes the light attenuation factor for a given distance.
Namespace: DigitalRune.GraphicsAssembly: DigitalRune.Graphics (in DigitalRune.Graphics.dll) Version: 1.2.0.0 (1.2.1.14562)
Syntax public static float GetDistanceAttenuation(
float distance,
float range,
float exponent
)
Public Shared Function GetDistanceAttenuation (
distance As Single,
range As Single,
exponent As Single
) As Single
public:
static float GetDistanceAttenuation(
float distance,
float range,
float exponent
)
static member GetDistanceAttenuation :
distance : float32 *
range : float32 *
exponent : float32 -> float32
Parameters
- distance
- Type: SystemSingle
The distance to the light's origin. - range
- Type: SystemSingle
The range of the light. - exponent
- Type: SystemSingle
The falloff exponent.
Return Value
Type:
SingleThe light attenuation factor.
Remarks
The intensity of the light continually decreases from the origin up to range. At a distance
of range the light intensity is 0. This method computes the attenuation factor at a given
distance.
The attenuation factor is computed as follows:
Distance | Attenuation Factor |
---|
distance ≤ 0 | 1 |
0 < distance < 1 | 1 - (distance / range)exponent |
distance ≥ 1 | 0 |
See Also