The POLYSHADE function returns a shaded-surface representation of one or more solids described by a set of polygons. This function accepts, as arguments, an array of three-dimensional vertices and a list of the indices of the vertices that describe each polygon. Output is a two-dimensional byte array containing the shaded image unless the current graphics output device is the Z-buffer. If the current output device is the Z-buffer, the results are merged with the Z-buffer's contents and the function result contains a dummy value.

Shading values are determined from one of three sources: a light source model, a user-specified array containing vertex shade values, or a user-specified array containing polygon shade values.

The shaded surface is constructed using the scan line algorithm. The default shading model is a combination of diffuse reflection and depth cueing. With this shading model, polygons are shaded using either constant shading, in which each polygon is given a constant intensity, or with Gouraud shading where the intensity is computed at each vertex and then interpolated over the polygon. Use the SET_SHADING procedure to control the direction of the light source and other shading parameters.

User-specified shading arrays allow " 4-dimensional" displays that consist of a surface defined by a set of polygons, shaded with values from another variable.

A (3, *
n*
) array containing the X, Y, and Z coordinates of each vertex. Coordinates can be in either data or normalized coordinates, depending on which keywords are present.

The X, Y, and Z coordinates of each vertex can, alternatively, be specified as three array expressions of the same dimensions.

An integer or longword array containing the indices of the vertices for each polygon. The vertices of each polygon should be listed in counterclockwise order when observed from outside the surface. The vertex description of each polygon is a vector of the form: [*
n*
, *
i*
_{
0}
, *
i*
_{
1}
, ..., *
i*
_{
n-1}
] and the array *
Polygons*
is the concatenation of the lists of each polygon. For example, to render a pyramid consisting of four triangles, *
Polygons*
would contain 16 elements, made by concatenating four, four-element vectors of the form [3, *
V*
_{
0}
, *
V*
_{
1}
, *
V*
_{
2}
]. *
V*
_{
0}
, *
V*
_{
1}
, and *
V*
_{
2}
are the indices of the vertices describing each triangle.

Set this keyword to indicate that the vertex coordinates are in data units, the default coordinate system.

Set this keyword to indicate that coordinates are in normalized units, within the three dimensional (0,1) cube.

An array expression, with the same number of elements as there are polygons defined in the *
Polygons*
array, containing the color index used to render each polygon. No interpolation is performed if all pixels within a given polygon have the same shade value. For most displays, this parameter should be scaled into the range of bytes.

An array expression, with the same number of elements as *
Vertices*
, containing the color index at each vertex. The shading of each pixel is interpolated from the surrounding SHADE values. For most displays, this parameter should be scaled into the range of bytes.

**CAUTION: **
When using the SHADES keyword on True Color devices, we recommend that decomposed color support be turned off, by setting DECOMPOSED=0 for

DEVICE
.

Set this keyword to use the three-dimensional to two-dimensional transformation contained in the homogeneous 4 by 4 matrix !P.T. Note that if T3D is set, !P.T must contain a valid transformation matrix. The SURFACE, SCALE3, and T3D procedures (and others) can all be used to set up transformations.

The maximum shading value when light source shading is in effect. The default value is one less than the number of colors available in the currently selected graphics device.

The number of columns in the output image array. If this parameter is omitted, the number of columns is equal to the X size of the currently selected display device.

Warning: The size parameters should be explicitly specified when the current graphics device is PostScript or any other high-resolution device. Making the output image the default full device size is likely to cause an insufficient memory error.

POLYSHADE is often used in conjunction with SHADE_VOLUME for volume visualization. The following example creates a spherical volume dataset and renders an isosurface from that dataset:

SPHERE = FLTARR(20, 20, 20) *;
Create an empty, 3D array.*

FOR X=0,19 DO FOR Y=0,19 DO FOR Z=0,19 DO $

SPHERE(X, Y, Z) = SQRT((X-10)^2 + (Y-10)^2 + (Z-10)^2)

*;
Create the spherical dataset.*

SHADE_VOLUME, SPHERE, 8, V, P *;
Find the vertices and polygons for a density level of 8.*

SCALE3, XRANGE=[0,20], YRANGE=[0,20], ZRANGE=[0,20]

*;
Set up an appropriate 3D transformation so we can see the sphere. This step is very important.*

image = POLYSHADE(V, P, /T3D) *;
Render the image. Note that the T3D keyword has been set so that the previously-established 3D transformation is used.*

PROJECT_VOL , RECON3 , SET_SHADING , SHADE_SURF , SHADE_VOLUME , VOXEL_PROJ