Positioning Lights in Data Space
This example creates a sphere and a cube to illustrate the effects of various properties on lighting. The variables
fac define the cube using the
sphere(36); h = findobj('Type','surface'); set(h,'FaceLighting','phong',... 'FaceColor','interp',... 'EdgeColor',[.4 .4 .4],... 'BackFaceLighting','lit') hold on patch('faces',fac,'vertices',vert,'FaceColor','y'); light('Position',[1 3 2]); light('Position',[-3 -1 3]); material shiny axis vis3d off hold off
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
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
FaceLighting (the default) to enhance the visibility of each side. The surface uses
FaceLighting because it produces the smoothest interpolation of lighting effects. The
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).
Since 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
material M-files can help you understand how various properties affect lighting.
|Back Face Lighting||Transparency|