3-D Visualization | ![]() ![]() |
Adding Lights to a Scene
This example displays the membrane surface and illuminates it with a light source emanating from the direction defined by the position vector [0
-2 1]
. This vector defines a direction from the axes origin passing through the point with the coordinates 0, -2, 1. The light shines from this direction towards the axes origin.
Creating a light activates a number of lighting-related properties controlling characteristics, such as the ambient light and reflectance properties of objects. It also switches to Z-buffer renderer if not already in that mode.
Illuminating Mathematical Functions
Lighting can enhance surface graphs of mathematical functions. For example, use the ezsurf
command to evaluate the expression
Now add lighting using the lightangle
command, which accepts the light position in terms of azimuth and elevation.
view(0,75) shading interp lightangle(-45,30) set(gcf,'Renderer','zbuffer') set(findobj(gca,'type','surface'),... 'FaceLighting','phong',... 'AmbientStrength',.3,'DiffuseStrength',.8,... 'SpecularStrength',.9,'SpecularExponent',25,... 'BackFaceLighting','unlit')
After obtaining surface object's handle using findobj
, you can set properties that affect how the light reflects from the surface. See the "Properties That Affect Lighting" section of this chapter for more detailed descriptions of these properties.
![]() | Light Objects | Properties That Affect Lighting | ![]() |