Lights

A 3D model can incorporate any number of light sources. It should include at least one so that you are able to see the objects in the model. In practice, you might want to add a few—a single light source can produce a somewhat stark appearance. WPF offers four different kinds of light.

Tip

Although lights form part of the model—the base Light class derives from Model3D—they are not visible. They affect only the way in which other elements in the 3D scene are rendered. If you want a bright-looking object to be visible, representing the light, you would need to add one or more 3D shapes to provide that appearance.

AmbientLight

The simplest light source is AmbientLight. This provides an even illumination of all objects in the scene regardless of their location or orientation. Example 17-13 shows an AmbientLight.

Example 17-13. AmbientLight

<AmbientLight Color="White" />

The only property to set on an ambient light is Color. This property is present on all lights, and it indicates the color of the light emitted by the source. Note that the Color property determines not just the color of illumination, but also the intensity—White is the brightest color; a darker color such as Gray will provide less illumination. Figure 17-18 shows the results. This makes it clear that you would not normally use an AmbientLight as your only source of illumination. The sphere rendered in this example is the same one shown in Figure 17-14, but in that earlier figure, we could see reflected highlights and ...

Get Programming WPF, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.