You can specify the reflectance characteristics of patch and surface objects and thereby affect the way they look when lights are applied to the scene. It is likely you will adjust these characteristics in combination to produce particular results.
Also see the
for a convenient way to produce certain lighting effects.
Ambient light is a directionless light that shines uniformly
on all objects in the scene. Ambient light is visible only when there
are light objects in the axes. There are two properties that control
ambient light —
an axes property that sets the color, and
a property of patch and surface objects that determines the intensity
of the ambient light on the particular object.
This illustration shows three different ambient light colors at various intensities. The sphere is red and there is a white light object present.
The green [0 1 0] ambient light does not affect the scene because there is no red component in green light. However, the color defined by the RGB values [.5 0 1] does have a red component, so it contributes to the light on the sphere (but less than the white [1 1 1] ambient light).
The size of the specular highlight spot depends
on the value of the patch and surface object's
Typical values for this property range from 1 to 500, with normal
objects having values in the range 5 to 20.
The color of the specularly
reflected light can range from a combination of the color of the object
and the color of the light source to the color of the light source
only. The patch and surface
controls this color. This illustration shows a red sphere illuminated
by a white light. The values of the
range from 0 (object and light color) to 1 (light color).
The default value for
This setting reverses the direction of the vertex
normals that face away from the camera, causing the interior surface
to reflect light towards the camera. Setting
lighting on faces with normals that point away from the camera.
You can also use
BackFaceLighting to remove
edge effects for closed objects. These effects occur when
reverselit and pixels along the edge of
a closed object are lit as if their vertex normals faced the camera.
This produces an improperly lit pixel because the pixel is visible
but is really facing away from the camera.
This example creates a sphere and a cube and illuminates then with two light sources. The light objects are located at infinity, but in the directions specified by their position vectors.
% Create a sphere sphere(36); axis([-3 3 -3 3 -3 3]) hold on % Create a cube fac = [1 2 3 4;2 6 7 3;4 3 7 8;1 5 8 4;1 2 6 5;5 6 7 8]; vert = [1 1 1;1 2 1;2 2 1;2 1 1;1 1 2;1 2 2;2 2 2;2 1 2]; patch('faces',fac,'vertices',vert,'FaceColor','y'); % Add lights light('Position',[1 3 2]); light('Position',[-3 -1 3]); hold off
light functions define two light objects
located at infinity in the direction specified by the
These vectors are defined in axes coordinates [x, y, z].