Share via


Light Position, Range, and Attenuation (Windows Embedded CE 6.0)

1/6/2010

The position, range, and attenuation properties define a light's location in world space, and how the light it emits behaves over distance. As with all light properties, these are contained in a light's D3DMLIGHT structure.

Position

Light position is described using a D3DMVECTOR structure in the Position member of the D3DMLIGHT structure. The x-, y-, and z-coordinates are assumed to be in world space. Directional lights are the only type of light that do not 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. Directional lights do not use the range property.

Attenuation

Attenuation controls how a light's intensity decreases toward the maximum distance specified by the range property. Three D3DMLIGHT structure members represent light attenuation: Attenuation0, Attenuation1, and Attenuation2. These members contain floating-point values ranging from 0.0 through infinity, controlling a light's attenuation. Some applications set the Attenuation1 member to 1.0 and the others to 0.0, resulting in light intensity that changes as 1 / D, where D is the distance from the light source to the vertex. The maximum light intensity is at the source, decreasing to 1 / (Light Range) at the light's range. Typically, an application sets Attenuation0 to 0.0, Attenuation1 to a constant value, and Attenuation2 to 0.0.

You can combine attenuation values to get more complex attenuation effects. Or, you might set them to values outside the normal range to create even stranger attenuation effects; negative attenuation values make a light that gets brighter over distance.

See Also

Concepts

Light Properties