lighting

Specify lighting algorithm

Syntax

lighting flat
lighting gouraud
lighting none
lighting(ax,...)

Description

lighting selects the algorithm used to calculate the effects of light objects on all surface and patch objects in the current axes. In order for the lighting command to have any effects, however, you must create a lighting object by using the light or lightangle function.

lighting flat produces uniform lighting across each of the faces of the object. Select this method to view faceted objects.

lighting gouraud calculates the vertex normals and interpolates linearly across the faces. Select this method to view curved surfaces.

lighting none turns off lighting.

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

Examples

collapse all

Create a sphere. There is no light by default, which is the same as having a light and setting the algorithm to none.

sphere
axis equal

Call the lightangle function to create a light at an azimuth angle of -45 degrees and an elevation angle of 30 degrees. When you create the light, the default lighting algorithm is flat.

lightangle(gca,-45,30)

Change the lighting algorithm to gouraud.

lighting gouraud

Tips

The surf, mesh, pcolor, fill, fill3, surface, and patch functions create graphics objects that are affected by light sources. The lighting command sets the FaceLighting and EdgeLighting properties of surfaces and patches appropriately for the graphics object.

Introduced before R2006a