C3DLight::SetAttenuation |
Top Previous Next |
Syntax:
SetAttenuation(float att0, float att1, float att2)
Purpose:
Parameters: att0 - Constant attenuation factor. Returned value(s): None
Application: light1.SetAttenuation(0.01,0.0,0.0)
Class Hierarchy
Additional Info: The parameters can range from 0.0 to infinity but must never be negative. The attenuation of a light depends on the type of light and the distance between the light and the vertex position. To calculate attenuation, Direct3D uses the following equation:
Atten = 1/( att0i + att1i * d + att2i * d2)
The attenuation constants act as coefficients in the formula you can produce a variety of attenuation curves by making simple adjustments to them. You can set Attenuation1 to 1.0 to create a light that doesn't attenuate but is still limited by range, or you can experiment with different values to achieve various attenuation effects.
The attenuation at the maximum range of the light is not 0.0. To prevent lights from suddenly appearing when they are at the light range, an application can increase the light range. Or, the application can set up attenuation constants so that the attenuation factor is close to 0.0 at the light range. The attenuation value is multiplied by the red, green, and blue components of the light's color to scale the light's intensity as a factor of the distance light travels to a vertex.
See Also:
|