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.
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
light function. Lights are separate MATLAB graphic objects.
This example shows how to add a light source to a surface colored data grid. The toolbox manages light objects with the
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]) meshm(map,refvec,size(map),map); demcmap(map)
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).
Remove the edges of the bounding box and set a viewpoint of -30 degrees azimuth and 30 degrees altitude.
ax = gca; ax.Box = 'off'; view(-30,30)
To remove a light (when there is only one) from the current figure, use the