3-D Visualization Previous page   Next Page

Positioning Lights in Data Space

This example creates a sphere and a cube to illustrate the effects of various properties on lighting. The variables vert and fac define the cube using the patch function.

All faces of the cube have FaceColor set to yellow. The sphere function creates a spherical surface and the handle of this surface is obtained using findobj to search for the object whose Type property is surface. The light functions define two white (the default color) light objects located at infinity in the direction specified by the Position vectors. These vectors are defined in axes coordinates [x, y, z].

The patch uses flat FaceLighting (the default) to enhance the visibility of each side. The surface uses phong FaceLighting because it produces the smoothest interpolation of lighting effects. The material shiny command affects the reflectance properties of both the cube and sphere (although its effects are noticeable only on the sphere because of the cube's flat shading).

Because the sphere is closed, the BackFaceLighting property is changed from its default setting, which reverses the direction of vertex normals that face away from the camera, to normal lighting, which removes undesirable edge effects.

Examining the code in the lighting and material M-files can help you understand how various properties affect lighting.


Previous page  Back Face Lighting Transparency Next page

© 1994-2005 The MathWorks, Inc.