This example shows how to 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.
Add a light source to a surface colored data grid using
lightm. First, load elevation data and a geographic cells reference object for the Korean peninsula. Display the data without lighting effects using
meshm. Apply a colormap appropriate for elevation data using
demcmap. Eliminate extra white space around the map using
load korea5c axesm('miller','MapLatLimit',[30 45],'MapLonLimit',[115 135]) meshm(korea5c,korea5cR,size(korea5c),korea5c) demcmap(korea5c) tightmap
Place a light source at the northwest corner of the grid, one degree high, using
lightm function is similar to the MATLAB® function
light, but accepts latitude and longitude inputs instead of 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.
material([0.7 0.9 0.8])
By default, the lighting is flat (plane facets). Change the light to use Gouraud shading (interpolated normal vectors at facet corners).
Remove the edges of the bounding box. Change the view by specifying an azimuth of -30º and an altitude of 30º.
ax = gca; ax.Box = 'off'; view(-30,30)
If there is only one light in the current figure, you can remove it using