The surfl function displays a shaded surface based on a
combination of ambient, diffuse, and specular lighting models.
surfl(...,'light') produces a colored, lighted surface using a
MATLAB light object. This produces results different from the default
lighting method, surfl(...,'cdata'), which changes the color
data for the surface to be the reflectance of the surface.
surfl(...,s) specifies the direction of the light
source. s is a two- or three-element vector that specifies the
direction from a surface to a light source. s = [sx sy sz]
or s = [azimuth elevation]. The default s is 45°
counterclockwise from the current view direction.
surfl(X,Y,Z,s,k) specifies the reflectance constant. k is a
four-element vector defining the relative contributions of ambient
light, diffuse reflection, specular reflection, and the specular shine
coefficient. k = [ka kd ks shine] and defaults to
[.55,.6,.4,10].
"Ambient" light refers to light coming from all directions,
"diffuse" refers to the light diffused (a.k.a. spread) from the
object in all directions, "specular" to the light reflected as in a
miror.
E.g., chalk has ks=0 (no reflection at all), while a perfect
mirror has kd=0 (it reflects each light ray along a single
direction, without diffusing it).
Thus, k=[0, 1, 0, shine] means that the object is lighted
only by a "light beam" (no ambient light), and it is not
reflecting at all (ks=0).
The ordering of points in the X, Y, and Z matrices
defines the inside and outside of parametric surfaces. If you want the
opposite side of the surface to reflect the light source,
use surfl(X',Y',Z'). Because of the way surface normal vectors
are computed, surfl requires matrices that are at least
3-by-3.
Example: View peaks using colormap-based lighting.
[x,y] = meshgrid(-3:1/8:3);
z = peaks(x,y);
surfl(x,y,z);
shading interp
colormap(gray);