SET_SHADING Procedure

Modifies the light source shading parameters affecting the output of SHADE_SURF and POLYSHADE.

Usage

SET_SHADING

Input Parameters

None.

Keywords

Gouraud—Controls the method of shading the surface polygons of the POLYSHADE procedure:

If set to nonzero (the default), the Gouraud shading method is used.

Otherwise, each polygon is shaded with a constant intensity.

Gouraud shading interpolates intensities from each vertex along each edge. Then, when scan converting the polygons, the shading is interpolated along each scan line from the edge intensities. Gouraud shading is slower than constant shading, but usually results in a more realistic appearance.

Note:

The Gouraud keyword does not affect the output of SHADE_SURF.

Light—3-element vector specifying the light source’s direction. The default vector is [0, 0, 1], with the light rays parallel to the Z-axis.

Reject—If set (the default), causes polygons to be rejected as being hidden if their vertices are ordered in a clockwise direction as seen by the viewer.

You should always set Reject when rendering enclosed solids whose original vertex lists are in counterclockwise order.

You may also set Reject when rendering surfaces that are not closed or are not in counterclockwise order, although this may cause shading anomalies at boundaries between visible and hidden surfaces to occur.

Discussion

SET_SHADING keywords let you control the light source direction, shading method, and the rejection of hidden surfaces. SET_SHADING first resets its keywords to their default values. The values specified in the call then overwrite the default values.

Example

This example creates a spherical volume dataset and then renders two isosurfaces from that dataset. The first isosurface does not use the Gouraud method of shading but instead shades each polygon with a constant intensity. This is achieved by using SET_SHADING with the Gouraud keyword set to 0. The second isosurface uses the Gouraud method of shading, which is achieved by using SET_SHADING with the Gouraud keyword set to 1. The two images are shown in Spherical Isosurface with Constant Intensity Shading and Spherical Isosurface with Gouraud Shading.

; Create 3D single precision, floating-point array.
sphere = FLTARR(20, 20, 20)
; Create the spherical volume dataset.
FOR x=0L, 19 DO FOR y=0L, 19 DO FOR z=0L, 19 $
   DO sphere(x, y, z) = SQRT((x-10)^2 + (y-10)^2 + (z-10)^2)
; Find the vertices and polygons at a contour level of 7.
SHADE_VOLUME, sphere, 7, v, p
; Set up an appropriate three-dimensional transformation.
SURFACE, FLTARR(2, 2), /Nodata, /Save, $
   Xrange=[0, 20], Yrange=[0, 20], Zrange=[0, 20], $
   Xstyle=4, Ystyle=4, Zstyle = 4
; Turn Gouraud shading off.
SET_SHADING, Gouraud=0
; Render the image.
image = POLYSHADE(v, p, /T3d)
; Display the image.
TV, image
WAIT, 1
; Turn Gouraud shading on.
SET_SHADING, Gouraud=1
; Render the image.
image = POLYSHADE(v, p, /T3d)
; Display the image.
TV, image

Spherical Isosurface with Constant Intensity Shading

 

Spherical Isosurface with Gouraud Shading

See Also

POLYSHADE,  SHADE_SURF,  SHADE_SURF_IRR