Compartilhar via


Lighting Support

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

Microsoft® Direct3D® Mobile supports an unlimited number of lights per scene. The number of lights in the scene is only constrained by the capabilities of the driver. Lights are identified by index values. To create a light, you can call any of the light-related methods on the IDirect3DMobileDevice interface, such as IDirect3DMobileDevice::SetLight or IDirect3DMobileDevice::LightEnable, and pass it a new index value. The Direct3D Mobile middleware will detect this and automatically create the new light.

Lights are described by the D3DMLIGHT structure. To change the description of a light, call the IDirect3DMobileDevice::SetLight method.

You can enabled or disable a light by calling the IDirect3DMobileDevice::LightEnable method.

Ambient Lighting

Ambient lighting provides constant lighting for a scene. Because ambient lighting is not dependant on other lighting factors such as vertex normals, light direction, light position, or attenuation, it provides the same level of lighting to all object vertices. Ambient lighting is the fastest type of lighting, but produces the least realistic results.

Direct3D Mobile contains a single global ambient lighting property that can be used without creating any light. The application may set the global ambient lighting parameter by changing the D3DMRS_AMBIENT render state (see D3DMRENDERSTATETYPE), which is set to black by default when the device is created. The following equation describes the ambient lighting for a scene.

Ambient = M<SUB>a</SUB> * [L<SUB>a</SUB> + sum(La<SUB>i</SUB> * Atten<SUB>i</SUB>)]

For the notational conventions of this equation, see Lighting Equations.

See Also

Concepts

Lighting