C3DLight::SetAttenuation

Top  Previous  Next

Syntax:

 

SetAttenuation(float  att0, float  att1, float  att2)

 

Purpose:
Specifies how the light intensity changes over distance.

 

Parameters:

att0 - Constant attenuation factor.
att1 - Linear attenuation factor.
att2 - Quadratic attenuation factor.
 

Returned value(s):

None

 

Application:

light1.SetAttenuation(0.01,0.0,0.0)

 

Class Hierarchy
C3DObject
-------C3DLight

 

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)

 
Where d is the distance from vertex position to light position. If d is greater than the light's range, set by the SetRange method, Microsoft Direct3D makes no further attenuation calculations and applies no effects from the light to the vertex.

 

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:

SetRange