Documentation Center

  • Trial Software
  • Product Updates

Reflectance Characteristics of Graphics Objects

Specular and Diffuse Reflection

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 material command for a convenient way to produce certain lighting effects.

You can control the amount of specular and diffuse reflection from the surface of an object by setting the SpecularStrength and DiffuseStrength properties. This picture illustrates various settings.

Ambient Light

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 — AmbientLightColor is an axes property that sets the color, and AmbientStrength is 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).

Specular Exponent

The size of the specular highlight spot depends on the value of the patch and surface object's SpecularExponent property. Typical values for this property range from 1 to 500, with normal objects having values in the range 5 to 20.

This illustration shows a red sphere illuminated by a white light with three different values for the SpecularExponent property.

Specular Color Reflectance

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 SpecularColorReflectance property controls this color. This illustration shows a red sphere illuminated by a white light. The values of the SpecularColorReflectance property range from 0 (object and light color) to 1 (light color).

Back Face Lighting

Back face lighting is useful for showing the difference between internal and external faces. These pictures of cut-away cylindrical surfaces illustrate the effects of back face lighting.

The default value for BackFaceLighting is reverselit. 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 BackFaceLighting to unlit disables 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 BackFaceLighting is set to 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.

To illustrate this effect, the next picture shows a blowup of the edge of a lit sphere. Setting BackFaceLighting to lit prevents the improper lighting of pixels.

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.

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 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 files can help you understand how various properties affect lighting.

Was this topic helpful?