Next: , Previous: Data Flows for Drawing Spheres, Up: Usage of Sphere Drawing

26.1.6 Adjustment of the Lighting and Shading

The equation for determining the intensity of a particular pixel is as follows:

                                         _   _       _   _ G
             I = I    + (I   - I   ) (K  N . L + K  (R . O)
                  LOW     HI    LOW    D          S
               I      minimum intensity for a pixel. This provides for
                LOW   an ambient light level. Defaults to 10.
               I      maximum intensity for a pixel. Useful if the
                HI    display saturates below 255. Defaults to 255.
               K      coefficient of diffusive reflection, ie. uniform
                D     scattering of light. Defaults to 0.5.
               K      coefficient of specular reflection, ie. where
                S     light reflects in a particular direction. Defaults to
               _      Unit normal vector of the sphere's surface at the pixel
               N      coordinate.
               _      Unit vector pointing to the light source. Defaults to
               L      (0,0,1). A vector of (0,0,-1) is perfect backlighting
                      which sets all pixels to I   . (0,1,0) gives right lighting.
               _      Unit vector giving the reflected light vector off the
               R      surface. Computed as follows:
                             _     _   _ _   _
                             R = 2 N . L N - L
               _      Vector to observer. This is preset to (0,0,1)
               O      so that the observer is at z = infinity
               G      Glossiness exponent. This controls how accurately
                      the reflected light vector must point toward the
                      observer. Low values (3-6) give a metallic appearance.
                      Larger values (30-100) give a more plastic appearance.
                      Defaults to 6.

All negative dot products are converted to zero which models the opacity of the surface.

The commands for manipulating the shading parameters are as follows: BC — Set Background Color

BC color real
Sets the background color. The color is specified as either a string or an integer, see the color commands in Atom Manipulations in Sphere Drawing. The second parameter is an intensity which may range between 0 and 1. It selects what intensity the background color will be. GLOS — Set Glossiness Drawing Parameter

GLOS integer
Sets G to whatever value you specify. Negative arguments are converted to 0. LRAN — Set Lighting Range

LRAN integer integer
          Sets the lighting range. I    is set to the first argument.
          I   is set to the second argument. The range of permissible
          values are 0 to 255. LV — Set Lighting Vector

LV real real real
Set the X, Y, and Z components of the lighting vector to the three arguments, respectively. The vector is normalized automatically. SDCO — Set Lighting Coefficients

SDCO real real
Specular Diffuse COefficient setting. The specular and diffuse scattering coefficients are set to the first and second arguments, respectively. The coefficient are normalized so that their sum is one. SL — Show Lighting Parameters

Show Lighting parameters. Prints the various shading parameters.