Relief Mapping with Light Objects

In the exercise Light a Global Terrain Map, you created light objects to illuminate a Globe display. In the following one, you create a light object to mimic the map produced in Colored Surface Shaded Relief, which uses shaded relief computations rather than light objects.

The meshlsrm and surflsrm functions simulate lighting by modifying the colormap with bands of light and dark. The map matrix is then converted to indices for the new "shaded" colormap based on calculated surface normals. Using light objects allows for a wide range of lighting effects. The toolbox manages light objects with the lightm function, which depends upon the MATLAB® light function. Lights are separate MATLAB graphic objects.

For more information, consult the reference pages for lightm, daspectm, material, lighting, and view, along with Lighting, Transparency, and Shading (MATLAB).

Illuminate Color 3-D Relief Maps with Light Objects

This example shows how to add a light source to a surface colored data grid. The toolbox manages light objects with the lightm function.

Load Digital Elevation Model (DEM) data and display it. This example loads DEM data centered on the Korean peninsula. The example uses the meshm function to display the data, without lighting effects, and color it with terrain hues.

load korea
figure; axesm('MapProjection','miller',...
     'MapLatLimit',[30 45],'MapLonLimit',[115 135])

Create a light object with lightm function and place the light at the northwest corner of the grid, one degree high. (The lightm function is similar to the MATLAB light function, but it accepts latitude and longitude for positioning information, rather than x , y , and z .) Note that the figure becomes darker.


Exaggerate the vertical dimension to make any relief viewable in perspective. Note that the figure becomes darker still.


Set the ambient (direct), diffuse (skylight), and specular (highlight) surface reflectivity characteristics, respectively.


By default, the lighting is flat (plane facets). Change this to Gouraud shading (interpolated normal vectors at facet corners).

lighting Gouraud

Remove the edges of the bounding box and set a viewpoint of -30 degrees azimuth and 30 degrees altitude.

ax = gca;
ax.Box = 'off';

To remove a light (when there is only one) from the current figure, use the clmo function.