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
     
             where
               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
                      0.5.
     
               _      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.
                                                LOW
     
               _      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:

26.1.6.1 BC — Set Background Color

Syntax:
BC color real
Function:
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.
26.1.6.2 GLOS — Set Glossiness Drawing Parameter

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

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

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

Syntax:
SDCO real real
Function:
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.
26.1.6.6 SL — Show Lighting Parameters

Syntax:
SL
Function:
Show Lighting parameters. Prints the various shading parameters.