Main Content

lighting

Set lighting method

    Description

    lighting method specifies the method used by Light objects to light surfaces and patches in the current axes. Specifically, the lighting function sets the FaceLighting and EdgeLighting properties of the Surface and Patch objects in the current axes.

    For the lighting command to have any effect, create one or more Light objects using the light or lightangle functions.

    example

    lighting(ax,method) uses the axes specified by ax instead of the current axes (gca).

    Examples

    collapse all

    You can use different lighting methods to change the appearance of a sphere.

    Create a sphere. By default, there is no light.

    sphere
    axis equal

    Figure contains an axes object. The axes object contains an object of type surface.

    Create a light by calling the lightangle function and specifying an azimuth angle of –45 degrees and an elevation angle of 30 degrees. By default, the lighting method is flat, which applies light uniformly across the faces of the sphere that are facing the light source.

    lightangle(-45,30)

    Figure contains an axes object. The axes object contains an object of type surface.

    To better view the curved surface of the sphere, vary the light across the faces of the sphere by changing the lighting method to gouraud.

    lighting gouraud

    Figure contains an axes object. The axes object contains an object of type surface.

    Turn off all lighting. The sphere returns to its default visual state, as if there were no Light object in the axes.

    lighting none

    Figure contains an axes object. The axes object contains an object of type surface.

    Input Arguments

    collapse all

    Lighting method, specified as one of the values in this table.

    MethodEffect
    "flat"Apply light uniformly across each face. Use this method to view faceted objects.
    "gouraud"Vary the light across the faces. Calculate the light at the vertices and then linearly interpolate the light across the faces. Use this method to view curved surfaces.
    "none"Turn off lighting.

    Axes object. If you do not specify an axes object, then lighting specifies the method used by Light objects in the current axes.

    Version History

    Introduced before R2006a