Partager via


Material Properties

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

Material properties detail a material's diffuse reflection, ambient reflection, and specular highlight characteristics. Microsoft® Direct3D® Mobile uses the D3DMMATERIAL structure to carry all material property information. Material properties affect the colors that Direct3D Mobile uses to rasterize polygons that use the material. With the exception of the specular property, each property is described as an RGBA color that represents how much of the red, green, and blue parts of a given type of light it reflects, and an alpha blending factor — the alpha component of the RGBA color. The material's specular property is described in two parts: color and power. For more information, see Color Values for Lights and Materials.

Diffuse and Ambient Reflection

The Diffuse and Ambient members of the D3DMMATERIAL structure describe how a material reflects the ambient and diffuse light in a scene. Because most scenes contain much more diffuse light than ambient light, diffuse reflection plays the largest part in determining color. Additionally, because diffuse light is directional, the angle of incidence for diffuse light affects the overall intensity of the reflection. Diffuse reflection is greatest when the light strikes a vertex parallel to the vertex normal. As the angle increases, the effect of diffuse reflection diminishes. The amount of light reflected is the cosine of the angle between the incoming light and the vertex normal, as shown in the following illustration.

Aa916677.d39e24e0-f58f-46d8-b6ea-f94ab10711ce(en-us,MSDN.10).gif

Ambient reflection, like ambient light, is nondirectional. Ambient reflection has a lesser impact on the apparent color of a rendered object, but it does affect the overall color and is most noticeable when little or no diffuse light reflects off the material. A material's ambient reflection is affected by the ambient light set for a scene by calling the IDirect3DMobileDevice::SetRenderState method with the D3DMRS_AMBIENT flag (see D3DMRENDERSTATETYPE).

Diffuse and ambient reflection work together to determine the perceived color of an object, and are usually identical values. For example, to render a blue crystalline object, you create a material that reflects only the blue component of diffuse and ambient light. When placed in a room with a white light, the crystal appears to be blue. However, in a room that has only red light, the same crystal would appear to be black, because its material does not reflect red light.

Specular Reflection

Specular reflection creates highlights on objects, making them appear shiny. The D3DMMATERIAL structure contains two members that describe the specular highlight color as well as the material's overall shininess. You establish the color of the specular highlights by setting the Specular member to the desired RGBA color — the most common colors are white or light gray. The values you set in the Power member control how sharp the specular effects are.

Specular highlights can create dramatic effects. Drawing again on the blue crystal analogy: a larger Power value creates sharper specular highlights, making the crystal appear to be quite shiny. Smaller values increase the area of the effect, creating a dull reflection that make the crystal look frosty. To make an object truly matte, set the Power member to zero and the color in Specular to black. Experiment with different levels of reflection to produce a realistic appearance for your needs. The following illustration shows two identical models. The one on the left uses a specular reflection power of 10; the model on the right has no specular reflection.

Aa916677.46662244-585e-4046-8735-2825bd26b119(en-us,MSDN.10).gif

See Also

Concepts

Materials