DirectX SDK |
The position, range, and attenuation properties are used to define a light's location in world space, and how the light it emits behaves over distance. Like all light the properties you use in C++, these are carried within a light's D3DLIGHT7 structure.
Position
Light position is described using a D3DVECTOR structure in the dvPosition member of the D3DLIGHT7 structure. The x-, y-, and z-coordinates are assumed to be in world space. Directional lights are the only type of light that don't use the position property.
Range
A light's range property determines the distance, in world space, at which meshes in a scene no longer receive light emitted by that object. The dvRange member contains a floating-point value that represents the light's maximum range, in world space. Most applications set the range to the maximum possible value, D3DLIGHT_RANGE_MAX, which is defined in D3d.h. Directional lights don't use the range property.
Attenuation
Attenuation controls how a light's intensity decreases toward the maximum distance specified by the range property. Light attenuation is represented by three D3DLIGHT7 structure members: dvAttenuation0, dvAttenuation1, and dvAttenuation2. These members contain floating point values typically ranging from 0.0 to 1.0, controlling a light's constant, linear, and quadratic attenuation. Many applications set the dvAttenuation1 member to 1.0 and the others to 0.0, resulting in light intensity that attenuates evenly over distance—from maximum intensity at the source, to zero intensity at the light's range. You can combine attenuation values to get more complex attenuation effects. Or, you might set them to values outside of the normal range to create even stranger attenuation effects; negative attenuation values make a light that gets brighter over distance. For more information about the mathematical model that Direct3D uses to calculate attenuation, see Light Attenuation Over Distance. Like the range property, directional lights don't use the attenuation property.
The D3DLIGHT7 type includes members that your Visual Basic application uses to define a light's position, range, and attenuation properties. These describe a light's location in world space, and how the light it emits behaves over distance.
Position
Light position is described using a D3DVECTOR type in the position member of the D3DLIGHT7 type. The x-, y-, and z-coordinates are assumed to be in world space. Directional lights are the only type of light that don't use the position property.
Range
A light's range property determines the distance, in world space, at which meshes in a scene no longer receive light emitted by that object. The range member contains a floating-point value that represents the light's maximum range, in world space. Most applications set the range to the maximum possible value (18.446+e18). Directional lights don't use the range property.
Attenuation
Attenuation controls how a light's intensity decreases toward the maximum distance specified by the range property. Light attenuation is represented by three D3DLIGHT7 members: attenuation0, attenuation1, and attenuation2. These members contain floating point values typically ranging from 0.0 to 1.0, controlling a light's constant, linear, and quadratic attenuation. Many applications set the attenuation1 member to 1.0 and the others to 0.0, resulting in light intensity that attenuates evenly over distance—from maximum intensity at the source, to zero intensity at the light's range. You can combine attenuation values to get more complex attenuation effects. Or, you might set them to values outside of the normal range to create even stranger attenuation effects; negative attenuation values make a light that gets brighter over distance. For more information about the mathematical model that Direct3D uses to calculate attenuation, see Light Attenuation Over Distance. Like the range property, directional lights don't use the attenuation property.