home *** CD-ROM | disk | FTP | other *** search
/ Software 2000 / Software 2000 Volume 1 (Disc 1 of 2).iso / utilities / u222.dms / in.adf / RayTracer / RAY.Doc < prev    next >
Encoding:
Text File  |  1988-03-13  |  46.8 KB  |  934 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *            Copyright (c) 1987, David B. Wecker            *
  4.  *                All Rights Reserved                *
  5.  *                                    *
  6.  * This file is part of DBW_Render                    *
  7.  *                                    *
  8.  * DBW_Render is distributed in the hope that it will be useful, but    *
  9.  * WITHOUT ANY WARRANTY. No author or distributor accepts        *
  10.  * responsibility to anyone for the consequences of using it or for    *
  11.  * whether it serves any particular purpose or works at all, unless    *
  12.  * he says so in writing. Refer to the DBW_Render General Public    *
  13.  * License for full details.                        *
  14.  *                                    *
  15.  * Everyone is granted permission to copy, modify and redistribute    *
  16.  * DBW_Render, but only under the conditions described in the        *
  17.  * DBW_Render General Public License. A copy of this license is        *
  18.  * supposed to have been given to you along with DBW_Render so you    *
  19.  * can know your rights and responsibilities. It should be in a file    *
  20.  * named COPYING. Among other things, the copyright notice and this    *
  21.  * notice must be preserved on all copies.                *
  22.  ************************************************************************/
  23.  
  24.  Sections
  25.  ~~~~~~~~
  26.     Announcement    - announcement of software availability
  27.     Included        - what's in the package
  28.     Under Development    - what's currently being written
  29.     Background Info    - what is this package?
  30.     Running RAY        - how to run the ray tracer
  31.     Running RAY2    - how to run the post-processor
  32.     Running DISPLAY    - how to run the display program
  33.     Creating a .DAT file- what goes into the input file (the hardest part)
  34.     Source file info    - how to rebuild the package
  35.  
  36.  Announcement
  37.  ~~~~~~~~~~~~
  38. If you liked the ray traced images previously distributed... you're
  39. going to LOVE DBW_Render. This package is a FULL re-implementation of the Ray
  40. Tracer that I've been using on VAXen to create all those images.
  41.  
  42. It will run on a standard Amiga (with 512k of memory (and can be configured
  43. to run in 256k if necessary)). By adding AI-heuristics, elapsed time to
  44. compute an image is within the same order of magnitude as a VAX-780 (even
  45. though the Amiga doesn't have hardware floating point or virtual memory)!
  46. For example "glass" computes in 50 hours on an Amiga without the heuristics.
  47. With the heuristics, the image (at full resolution) can be computed in 11 
  48. hours.
  49.  
  50.  Included:
  51.  ~~~~~~~~~
  52.     RAY    - ray tracing program
  53.     RAY2    - post processor to create IFF/ILBM format files
  54.     DISPLAY    - general display program for RAY2's output
  55.     *.DAT    - sample input files
  56.     *.TMP    - sample RAY output files
  57.     *.ILBM    - sample HAM encoded pictures (RAY2 output)
  58.     *.c    - all MANX-Aztec C sources for the package
  59.     *.h    - all MANX-Aztec C include files for the package
  60.     RAY.DOC    - full documentation for the package
  61.     COPYING - General License Agreement
  62.  
  63. Please read the General License Agreement (file: COPYING) before proceeding.
  64.  
  65.  Under Development
  66.  ~~~~~ ~~~~~~~~~~~
  67. Depending on the level of interest in this software, I will continue work on: 
  68.  
  69.     DBW_ED3D a full 3-dimensional graphics editor (so you don't have to
  70.          mathematically specify the input file to RAY, you can just
  71.          draw it).
  72.  
  73.     DBW_FILM which creates a film loop of HAM images (so you can create
  74.          your own "juggler" type demos).
  75.  
  76.     ----     a version of the software using increased memory and 
  77.                  floating point co-processor.
  78.  
  79.     ----     maintenance and enhancements to the current package.
  80.  
  81.  Background Information
  82.  ~~~~~~~~~~ ~~~~~~~~~~~
  83. The DBW_Render package uses an algorithm called Distributed Ray Tracing.
  84. In addition to neatly solving the hidden surface problem, ray tracing
  85. (in general) affords the opportunity for doing excellent (that is,
  86. highly realistic) shading and illumination calculations.
  87.  
  88. This package is written in MANX-Aztec C and runs on any AMIGA system. The
  89. RAY program knows how to create images composed of four primitive
  90. geometric objects: spheres, parallelograms, triangles, and flat circular
  91. rings (disks with holes in them). Some of the features of the program
  92. are:
  93.  
  94.     Determination of correct shadows cast by arbitrarily shaped objects,
  95.     onto arbitrarily shaped objects, due to arbitrarily placed light
  96.     sources.
  97.  
  98.     Diffuse and specular reflections (with arbitrary levels of gloss or
  99.     polish).  Rudimentary modeling of object-to-object diffusely 
  100.         reflected light is also implemented, that among other things 
  101.         accurately simulates color bleed effects from adjacent contrasting 
  102.         colored objects.
  103.  
  104.     Mirror reflections, including varying levels of mirror smoothness
  105.     or perfection.
  106.  
  107.     Refraction and translucency (which is akin to variable microscopic
  108.     smoothness, like the surface of etched glass).
  109.  
  110.     Two types of light sources: purely directional (parallel rays from
  111.     infinity) of constant intensity, and spherical sources (like light
  112.     bulbs, which cast penumbral shadows as a function of radius and
  113.     distance) where intensity is determined by the inverse square law.
  114.  
  115.     Photographic depth-of-field.  That is, the virtual camera may be
  116.     focused on a particular object in the scene, and the virtual
  117.     camera's aperture can be manipulated to affect the sharpness of
  118.     foreground and background objects.
  119.  
  120.     Solid texturing.  Normally, a particular object (say a sphere) is
  121.     considered to have constant properties (like color) over the entire
  122.     surface of the object, often resulting in fake looking objects.
  123.     Solid texturing is a way to algorithmically change the surface
  124.     properties of an object (thus the entire surface area is no longer of
  125.     constant nature) to try and model some real world material.
  126.     Currently the program has built in rules for modelling wood, marble,
  127.     bricks, snow covered scenes, water (with arbitrary wave sources),
  128.     plus more abstract things like color blend functions.
  129.  
  130.     Fractals.  The program implements what's known as recursive triangle
  131.     subdivision, which creates all manners of natural looking surface
  132.     shapes (like broken rock, mountains, etc.).  The character of the
  133.     fractal surface (degree of detail, roughness, etc.) is controlled by
  134.     parameters fed to the program.
  135.  
  136.     AI heuristics to complete computation of a scene within a user
  137.     specified length of time.
  138.  
  139. When the RAY program runs, it reads a sort of command file, that contains a
  140. geometric description of the scene to be rendered, plus desired global 
  141. lighting conditions, camera parameters, etc.  Then the program computes for 
  142. a long time, writing each scan line to disk as it computes it. The format of
  143. a scanline (in the .TMP) file is:
  144.  
  145.     <line  number>    -   2 bytes long
  146.     <red   pixels>    - 160 bytes long (4 bits per pixel)
  147.     <green pixels>    - 160 bytes long
  148.     <blue  pixels>  - 160 bytes long
  149.  
  150. For an entire screen (400 scan lines) this file is 192,800 bytes. A second
  151. program is run (RAY2) to obtain one of three possible output files:
  152.  
  153.     4096 colors (HAM) encoded interlaced 320x400 resolution
  154.       32 colors               interlaced 320x400 resolution
  155.       32 colors                          320x200 resolution
  156.  
  157. All of the file formats are standard IFF/ILBM and may be displayed by the
  158. supplied DISPLAY program. In addition, the last version (320x200) may be
  159. edited by any standard graphic package (e.g., DPaint). Others may be
  160. able to handle the more complex first two.
  161.  
  162. In all, the DBW_Render package represents about 4000 lines of C code. 
  163. It is largely based on original algorithms for the VAX by Tom Dahl and
  164. Tone Engel at Digital Equipment Corporation. The AMIGA version has taken
  165. several months to create.
  166.  
  167.  Running RAY
  168.  ~~~~~~~~~~~
  169.  
  170. REMINDER:    BEFORE RUNNING ANYTHING MAKE SURE YOU BACKUP THIS DISK!!!
  171.  
  172. Once you have an input file (described below in the "Creating a .DAT file"
  173. section) you can run the ray tracer. Remember that the output of the
  174. Ray Tracer (for a full screen) will be 192,800 bytes or a little over
  175. 400 blocks so make sure you have enough free space on the disk you are
  176. running on. It is NOT suggested that you direct the output to RAM: since
  177. if the machine crashes you will lose all of your work. In addition make
  178. sure you have a STACK of at least 10000 before you start!
  179.  
  180. If you have a file called GLASS.DAT for input, you can type:
  181.  
  182.     1> ray glass
  183.  
  184. The program will start running. All of the options are in the .DAT file.
  185. See the file GLASS.DAT (distributed with the package) for an example.
  186. As the program runs, it will write to the file GLASS.TMP. If you want
  187. different names for the input and output files, then run the program with
  188. no parameters:
  189.  
  190.     1> ray
  191.  
  192. at which point you will be prompted for the input file:
  193.  
  194.     Scene description file?
  195.  
  196. to which you could answer GLASS.DAT. The program will then ask for the
  197. name of the output file:
  198.  
  199.     File name to save picture (.tmp)?
  200.  
  201. to which you could answer DF1:GLASS.TMP.
  202.  
  203. The program will now compute the picture. Note that 4 extra scan lines
  204. before and after your scene are ALWAYS computed, so if you told the program
  205. to do a full screen (command "& 0 400" in the command file) you will notice
  206. that the program will start at scan line -4 and will and at scan line 403.
  207. This is due to one requirement of the AI-heuristics to fill a scan line cache
  208. before output can occur.
  209.  
  210. When the program finishes, it will give you a bunch of statistics about
  211. the picture. One of the most interesting is the number of pixels GUESSED as
  212. opposed to the number of pixels COMPUTED. This will give you and idea of how
  213. high a quality output to expect (0 guessed = perfect). These numbers are
  214. affected by the amount of time you give the program to compute the
  215. picture in ("R" command in the command file).
  216.  
  217.  Running RAY2
  218.  ~~~~~~~ ~~~~
  219. After RAY has completed, the output .TMP file (or files) may be 
  220. post-processed by RAY2.  Multiple files may be given to RAY2 for several 
  221. reasons:
  222.  
  223.     1) The machine crashed and so you have one partial file and another
  224.        that has the rest of the scan lines in it.
  225.  
  226.     2) You decided to do the picture in strips and have a seperate file
  227.        for each strip.
  228.  
  229.     3) You did the entire picture, but there are blurry scan lines around
  230.        complex objects (like light sources) because you didn't give it
  231.        enough time... so you recomputed the bad sections allowing more
  232.        time.
  233.  
  234. These will become clearer as we do the examples. To run the program, type:
  235.  
  236.     1> ray2 glass
  237.  
  238. this will open file GLASS.TMP (which was output from RAY), scan the file
  239. finding the most used colors, open a custom screen, create a HAM mode image
  240. on the screen and will then read back the image from the screen creating
  241. GLASS.ILBM. When the program is done, it will flash the screen at which point
  242. you can hit the (invisible) close gadget in the upper left corner to exit
  243. the program.
  244.  
  245. While the program is creating the output file, it will complement the first
  246. pixel on each scan line it computes so that you can see its progress through
  247. the picture.
  248.  
  249. An example of using ALL options for the RAY2 program is:
  250.  
  251.     1> ray2 -c 1 -h 1 -l 1 -o glass.ilbm glass
  252.  
  253. Where the options are:
  254.  
  255.     -c     = is compression allowed  (0 or 1) (default = yes = 1)
  256.     -h     = is HAM mode to be used  (0 or 1) (default = yes = 1)
  257.     -l     = is LACE mode to be used (0 or 1) (default = yes = 1)
  258.     -o     = name of the output file to create
  259.     <name>    = upto 10 input file names
  260.  
  261. The example shown will create an image exactly like the previous example
  262. (since all defaults are being taken). If we wanted the simplest picture
  263. (that something like DPaint could edit) and we had several input files,
  264. we could type:
  265.  
  266.     1> ray2 -h 0 -l 0 -o glass.pic glass1 glass2 glass
  267.  
  268. In this example we are using multiple input files. The program will ALWAYS
  269. use scanlines from files earlier in the command line (if possible). So for
  270. example, GLASS.TMP (on the distribution disk) contains a 12 hour complete
  271. picture. GLASS1.TMP and GLASS2.TMP contain scanlines around the light sources
  272. (that are blurry in GLASS.TMP) but with a resolution of 24 hours (so that
  273. they're much better (each took between 1 and 2 hours to compute)).
  274.  
  275. This program also uses a heuristic to figure out how to fold 4096 colors
  276. into 32 when you turn HAM mode off.
  277.  
  278.  Running DISPLAY
  279.  ~~~~~~~ ~~~~~~~
  280. DISPLAY is a VERY simple program to run, all you need to say is:
  281.  
  282.     1> display glass
  283.  
  284. and GLASS.ILBM will get displayed. If you have a different extension, then
  285. type the full file name:
  286.  
  287.     1> display glass.pic
  288.  
  289. The picture will be displayed until you click the mouse on the invisible 
  290. close gadget in the upper left corner of the screen. Remember that you can 
  291. use Left-Amiga-N and Left-Amiga-M to push this screen behind the Workbench 
  292. and pull it back in front.
  293.  
  294.  Creating a .DAT file
  295.  ~~~~~~~~ ~ ~~~~ ~~~~
  296. Okay, now the hard part: the contents of the script input file.  The
  297. file is a standard ASCII text file, with each line forming a separate
  298. object or command to RAY.  The lines begin with a command character
  299. (which is CASE SENSITIVE).  The command characters are:
  300.  
  301. R   Set resolution (optional, if missing, program will default to 12.0 hours)
  302. N   Global index of refraction (optional, default = 1.0)
  303. Z   Produce 2D histogram, rather than true image (default true image)
  304. a   Set overriding ambient proportion factor (default not overridden)
  305. A   Set antialiasing parameters (default no antialiasing)
  306. F   Set lens focus and aperture for depth of field (default infinite depth)
  307. M   Set global diffuse lighting parameters (default off)
  308. &   Define scan-line region of image to generate
  309. *,! comment, ignored
  310. b   Set background color
  311. w   Define a wave source
  312. g   Define a color blend texture
  313. n   Define a snowfall texture
  314. k   Define a 3D checkerboard texture
  315. H   Set global haze parameters (default no haze)
  316. f   Define fractal surface parameters
  317. m   Define a marble texture
  318. d   Define a wood texture
  319. e   Set the eye (camera) view parameters
  320. l   Define a directional light source
  321. L   Define a spherical light source
  322. {   Start an extent
  323. }   Terminate an extent
  324. s   Specify a spherical object
  325. t   Specify a planar triangular object
  326. x   Specify a fractal triangular object
  327. q   Specify a planar paralleligram object
  328. r   Specify a planar ring (annular) object
  329.  
  330. First, all color values consist of three numbers that range from 0 to 1.
  331. The color components are specified BLUE, GREEN, RED.
  332.  
  333. All position/direction values are three numbers ranging in whatever numbering
  334. system you want.  The numbers are X, Y, Z order.  Assuming you are
  335. looking into the screen in the negative Z direction, positive X is to
  336. the right, positive Y is up, and positive Z is out from the screen.
  337.  
  338. Okay, on to the specifics of the parameters that each command character
  339. requires.  First are listed all the general (environmental) commands, then 
  340. are listed the commands that create objects to be rendered in the scene.
  341.  
  342.         Global index of refraction (optional, default = 1.0)
  343. N INDEX
  344.     This single value is taken to be the index of refraction of "the
  345.     air", or put another way of the space between and outside of all
  346.     objects.
  347.  
  348.         Set resolution (optional, default = 12.0 hours)
  349. R RESOLUTION
  350.     The RESOLUTION value controls the MAXIMUM amount of time that a full
  351.     screen (400 scanlines) is allowed to take. This number should typically
  352.     be between 1.0 and 30.0 hours. The more time you give the program the
  353.     better the picture will be that you get.
  354.  
  355.         Produce 2D histogram, rather than true image
  356. Z FLAG
  357.     Normally, the contents of the .TMP file that the ray tracer produces
  358.     is a binary pixel version of the described scene.  However, for the
  359.     purposes of doing performance tuning of an antialiased scene, you can
  360.     include the command "Z 1" in the script file.  If done, the image file
  361.     that the ray tracer generates will not be the color scene that it 
  362.     normally is, but instead will be a sort of 2D histogram of how much 
  363.     computation each pixel in the scene consumed, displayed as a gray scale
  364.     (the brighter the pixel, the more computation).  Note that this command 
  365.     is only meaningfull if non-default values for the "A" command have been
  366.     used.  By default, basically an equal amount of time is spent on each 
  367.     pixel, (thus an image with Z set to 1 would come out a flat gray) but 
  368.     the "A" command tells the ray tracer to concentrate on certain types of
  369.     details in the scene to produce alias-free images.  Using the Z command 
  370.     with a parameter of 1 will allow you to see just where the ray tracer 
  371.     decided to spend more time, smoothing edges, etc.
  372.  
  373.         Set overriding ambient proportion factor
  374. a FACTOR
  375.     As described below, each object in the scene contains parameters that
  376.     control how bright the object appears if no light is shining on it.  Thus
  377.     you can set some objects to appear brigher when in shadow that other
  378.     objects.  As an alternative, you can specify the "a" command with a
  379.     parameter from 0 to 1, and this will cause the ambient color of all
  380.     objects in the scene to be a fraction of their diffuse brightness.
  381.     When the "a" command is used, the BGR ambient values for each object are
  382.     ignored (but they must still be specified).  A reasonable starting point
  383.     would be to set FACTOR from between .1 and .2.
  384.  
  385.         Set antialiasing parameters
  386. A COUNT THRESHHOLD
  387.     By default, the ray tracer computes one ray into the scene for each pixel
  388.     in the image (so a 320X4000 image computes ~128K rays).  Quite often, 
  389.     some unpleasant side effects of the digital generation process become 
  390.     apparent in a scene generated with one ray per pixel, for example 
  391.     diagonal lines are rendered as a sequence of discrete stairsteps -- the 
  392.     dreaded jaggies.  Such false features are called aliasing defects.  There
  393.     are numerous techniques devised to try to reduce the magnitude of these 
  394.     defects, collectively referred to as the process of anti-aliasing.
  395.     (There are many other types of aliasing defects besides jaggies.  An 
  396.     example of another "defect" is the razor-sharp shadows that are 
  397.     traditionally found in computer generated imagery -- real-world shadows 
  398.     are always at least a teensy bit diffuse.)
  399.  
  400.     The COUNT parameter determines how many rays will be traced for each 
  401.     pixel in the scene -- the more, the better, but the slower the computing.
  402.     A good starting value is 4. What happens is that a bunch of rays (e.g. 4)
  403.     are sent into the pixel cone at random -- they are "distributed" across 
  404.     the horizontal and vertical dimensions.  Thus, this ray tracer is said to
  405.     implement Distributed Ray Tracing.
  406.  
  407.     The THRESHHOLD value relates to a rather complicated feature in the ray
  408.     tracer called Statistically Optimized Distributed Ray Tracing.  The way
  409.     this works is that the program computes the intensities of the bunch of
  410.     rays that are distributed into the pixel.  In this example, say there are
  411.     four rays in the bunch.  The program computes the statistical variance of
  412.     the four resulting intensities.  If the variance is small, the odds are
  413.     that the portion of the scene being imaged is a smooth patch.
  414.     Thus a good approximation to the ideal intensity of that pixel has been
  415.     computed.  But let's say that the pixel happens to fall on a diagonal 
  416.     edge. Some of the distributed rays will be cast to one side of the edge,
  417.     and some of them to the other.  Thus the variance will be high.  The 
  418.     program looks at this, and if the variance is past the THRESHHOLD value,
  419.     will distribute another group of (in this case) four rays into the pixel.
  420.     Then the variance of the eight rays will be examined, and the process 
  421.     repeated until the required smoothness has been reached (or some 
  422.     arbitrarily large number of rays have been cast, and the process halts).
  423.     Setting THRESHHOLD to value of 1.0 or higher generally will force no 
  424.     extra groups of rays to be cast, beyond the initial group of COUNT rays.
  425.     Meaningfull values of THRESHHOLD generally fall in the .0001 to .1 range.
  426.  
  427.         Set lens focus and aperture for depth of field
  428. F APERTURE FOCUS
  429.     This command is optional; if omitted, the scene will be rendered such
  430.     that all objects will be in perfect focus (a pin-hole camera effect).
  431.     With this command, you can add depth-of-field effects to a scene (though
  432.     at great computation speed degradation, as described below).
  433.     The APERTURE parameter specifies the radius of the hypothetical lens
  434.     in the camera that is taking the picture of the scene.  FOCUS sets the
  435.     distance from the camera (or eye) at which objects will appear in perfect
  436.     focus.  The magnitude of both values depends upon the coordinate system
  437.     in use by your scene, of course, but here is an example for determining a
  438.     reasonable camera aperture.  Say that one unit of distance represents an
  439.     inch.  Assume you set the focus distance to 100 inches; with this scale,
  440.     a reasonable value for aperture is 0.5 to 2.0.
  441.  
  442.     In order to achieve a good quality smooth blurring of the foreground and
  443.     background, you will need to set the antialiasing parameters up from 
  444.     their defaults (with the A command).  A good start would be 20 to 30 
  445.     rays per pixel; the THRESHHOLD value doesn't matter much; it could be 
  446.     set to 1.
  447.  
  448.         Set global diffuse lighting parameters
  449. M COUNT NUMERATOR DENOMINATOR
  450.     This command relates to the realistic propagation of light as it reflects
  451.     from object to object in the scene.  Traditionally, computer lighting
  452.     models operate such that if an object is directly visible from a light
  453.     source, then the surface of the object is colored according to the
  454.     material's properties, the color and strength of the light, etc.  For
  455.     those objects or portions of objects that are not in the path of a light
  456.     source (aka are in shadow), they are rendered black.  Well, this is
  457.     usually artificial looking, and so a constant dim color is assigned to
  458.     areas in shadow.  (In fact, this program has provisions for this as well,
  459.     the ambient parameters of each object, plus the "a" command.)
  460.  
  461.     But in reality, shadows are filled in with light bounced off walls, etc.
  462.     The M command can be employed to model this diffuse propagation of light
  463.     from object to object.  (Sadly, once again performance suffers
  464.     significantly if you choose to do this, since a great deal of information
  465.     about the scene needs to be collected and analyzed to determine how the
  466.     shadow fill-in should occur.)  How this program does this is to, for each
  467.     pixel, sample extra rays from the surface being rendered, out into the
  468.     scene in random directions to see what other nearby surfaces are acting
  469.     as reflectors, etc.  The COUNT parameter controls how many samples to
  470.     take per pixel; values from 10 on up are okay, but 100 or more are needed
  471.     to render smooth color bleeding from surface to surface, etc.
  472.     The NUMERATOR and DENOMINATOR derive from the recursive nature of the
  473.     ray tracing process: in the process of calculating a ray on the surface
  474.     being rendered, assume the ray strikes an adjacent surface.  Well, from
  475.     THAT surface, another COUNT set of rays will ne sampled, to determine
  476.     ITS color, etc.; thus the process exponentially generates rays that need
  477.     to be computed.  To avoid this recursive growth, the number of sample 
  478.     rays that are done per recursion level is scaled from the initial COUNT 
  479.     value, according to the supplied NUMERATOR and DENOMINATOR values.  For
  480.     example values of 1 and 2 respectively will reduce by half the number of
  481.     samples taken at each recursion level.  Normally, even this is not a fast
  482.     enough decay, so 1/3 or 1/4 is better, without much noticable loss in 
  483.     resulting color fidelity.  In fact, setting NUMERATOR to 0 is not 
  484.     unreasonable.
  485.  
  486.         Define scan-line region of image to generate
  487. & FIRST LAST
  488.     If this command is omitted, the entire image bitmap will be calculated
  489.     (all 400 scan lines).   This command tells the program only to produce
  490.     those scans from FIRST to LAST-1 inclusive.  Once done, the resulting
  491.     fragment images can be combined into one whole image file.   In this way,
  492.     a particularly complex scene may be distributed into a number of CPUs,
  493.     resulting in shorter elapsed generation time. Picture merging is
  494.     accomplished by RAY2).
  495.  
  496.         Set background color
  497. b BLUE GREEN RED
  498.     The simple color value that will be displayed if no objects are
  499.     visible at a given point in the scene.
  500.  
  501.         Define a wave source
  502. w CENTERX CENTERY CENTERZ  WAVELENGTH AMPLITUDE DAMP PROPAGATE
  503.     A number of features in the program use wave sources as a basis for
  504.     calculating various effects (most notably the production of rippled
  505.     surfaces, such as water).  You can define up to 100 wave sources per
  506.     scene.  There is only one "wave source table" stored by the program;
  507.     all of the features that use waves use the same waves.
  508.     The first three values specify the coordinate from which the concentric
  509.     wave fronts emanate from.  WAVELENGTH sets the crest-to-crest distance
  510.     for the wave.  The AMPLITUDE value determines, in an abstract manner,
  511.     the height of the wave at the origin.  The height is not specified in
  512.     normal distance units; rather it is a fixed scale frational value, in the
  513.     approximate range of 0.1 (small, flat waves) to 0.5 (strong waves).
  514.     The DAMP value controls the damping of successive trains of waves.  The
  515.     value 1.0 means no damping; the waves will contine out to infinity from
  516.     the source.  Value 0.7 means that successive crests will be 70% the 
  517.     height of the preceeding crest.  The PROPAGATE value controls what phase
  518.     the wave starts broadcasting at; the value ranges from 0.0 (starting at a
  519.     crest at the origin) through 0.5 (180 degrees out of phase -- a trough)
  520.     and back to 1.0 (a crest).  This can be used in sequenced frames to
  521.     produce moving waves.
  522.  
  523.         Define a color blend texture
  524. g BCOLOR GCOLOR RCOLOR  START RANGE
  525.     Normally, an object is solidly and uniformly colored across its entire
  526.     surface.  This command lets you define a blend function which can be
  527.     applied to any object, in such a manner that the color of the object
  528.     will vary as a function of altitude (Y coordinate).  For example, a
  529.     sphere could be blue at the south pole, and yellow at the north pole,
  530.     with the color smoothly changing in the middle.
  531.     You can define up to ten blends per scene.
  532.     The three COLOR values specify the target color that the surface will
  533.     blend to with increasing Y coordinate (the initial color of the object
  534.     at low Y coordinate values is taken from the diffuse coeficients of
  535.     the object, as defined a ways below in the section on object properties).
  536.     The START value defines the low-Y coordinate where blending starts;
  537.     surface points below this Y level will be colored with the objects
  538.     diffuse coeficients.  The blending continues from START, continuing for
  539.     RANGE units upward.  At the level of START+RANGE, the blend would have
  540.     saturated out at the new COLOR value.  Points above START+RANGE will
  541.     maintain the new COLOR.  As an example, consider a sphere of radius
  542.     100 units positioned at the origin.  If START was set to -33, and RANGE
  543.     was set to 66, the result would be that the lower third of the sphere
  544.     would be its base diffuse color; the middle third would gradually change
  545.     color up until at the +33 level the color would attain the new COLOR;
  546.     the upper third of the sphere would maintain the new COLOR.
  547.  
  548.         Define a snowfall texture
  549. n START ALTITUDERANGE ALTFACTOR THRESHHOLD
  550.     This texture function is similar to the above blend texture.  It is
  551.     still under development.  This is intended to be used with the fratcal
  552.     surface capabilities described below.  The theory is that this will
  553.     distribute snow onto an object, the nature of which varies according to
  554.     the local surface slope and altitude.
  555.     START is the lower bound below which there can be no snowfall
  556.     accumulation, even on level surfaces.  Points on the surface above the
  557.     level of START+ALTITUDERANGE generally are solidly blanketed with snow.
  558.     ALTFACTOR is a scaler that lets you determine how important altitude is
  559.     in determining snow cover; value 0 means it is irrelevant (thus it is 
  560.     just a function of local surface slope).  Values above 1.0 generally 
  561.     result in a faster buildup of snow at the low end of the ALTITUDERANGE 
  562.     scale.  THRESHHOLD controls when a surface will be solidly blanketed, if
  563.     it meets the threshhold test.  Values for this parameter range from 0.0
  564.     (at which everything from START and above will be solidly coated,
  565.     regardless of slope) to 1.0, where coverage will be a continuous function
  566.     of slope and altitude.  Values around .4 result in surfaces from about
  567.     40 degrees of slope and flatter to be solidly covered.
  568.  
  569.         Define a 3D checkerboard texture
  570. k BCOLOR GCOLOR RCOLOR  X Y Z  JUNK1 JUNK2 JUNK3
  571.     You can define up to 10 checker textures per scene.
  572.     This texture function determines the color of points on the surface of
  573.     an object, using a 1- (layer), 2- (checker, column), or 3-dimensional
  574.     (block) model.  As the points on the surface of an object are colored,
  575.     this texture function can be used to determine whether the color of the
  576.     point in question is the object's base diffuse color, or is a different
  577.     specified color (controlled the three COLOR parameters to this command).
  578.     To determine whether the surface point is inside or outside which color
  579.     region, the X Y Z pattern size values are checked.  The X parameter
  580.     defines the width of successive layers from left to right; Y defines the
  581.     width of successive layers from top to bottom; Z is for front to back.
  582.     Note that one or more X Y or Z values can be set to 0.  This will cancel
  583.     any variation in the pattern in the corresponding dimention. For example, if X and Z are set to 10 but Y is 0, the effect will be of square 
  584.     vertical columns of alternating color.  If only Y were non-zero, the 
  585.     effect would be of horizontal layers of alternating color.  Setting all
  586.     three to non-zero creates a solid 3D block pattern.  The width of the 
  587.     layers in X Y and Z need not be the same (so you can make long flat 
  588.     blocks, for example).
  589.     JUNK1, JUNK2, and JUNK3 are currently not used and should be set to 0.
  590.  
  591.         Set global haze parameters
  592. H BCOLOR GCOLOR RCOLOR  DISTANCE
  593.     If this command is omitted, the color of each pixel in the scene is not
  594.     affected by how far the rendered surface is from the eyepoint.  By using
  595.     this haze command, you can cause objects in the distance to be
  596.     progressively tinted to a specified target haze color (the three COLOR
  597.     values).  Objects that are DISTANCE units or farther from the eyepoint
  598.     will be completely tinted or blended to the haze color and thus will
  599.     become effectively invisible.  Objects closer than this distance will be
  600.     continuously tinted from their true local color to the haze color, in
  601.     a linear manner as a function of distance.
  602.  
  603.         Define fractal surface parameters
  604. f RECURSIONLEVEL  XSCALE YSCALE ZSCALE  FINALTEXTURE
  605.     This texture can only be applied to 'x' objects as defined below.
  606.     The ray tracer so far only knows how to render a small set of primitive
  607.     object shapes, one of which is the three-sided polygon (triangle).
  608.     As described in the 'x' command below, the ray tracer does have the
  609.     capability to algorithmically generate compound objects that are
  610.     constructed out of large numbers of adjacent triangles forming what
  611.     is called a stochastic surface (often thought of as a fractal surface,
  612.     though in fact the relationship to the mathemacits of fractals is
  613.     limited).  This command defines parameters that the ray tracer uses in
  614.     constructing the mesh of triangular surface patches.
  615.  
  616.     You can define up to 10 fractal textures per scene.  In order to define
  617.     a fractal surface, you must also define at least one wave source with
  618.     the "w" command (the reason for this apparently unrelated need will be
  619.     explained).  The general fractal construction procedure is based on
  620.     recursive triangle subdivision, applying complex coordinate shifts when
  621.     determining the vertices of the subdivision triangles.  You start with
  622.     one master triangle that controls the gross size and orientation of the
  623.     final surface.  The original triangle is split into four triangles (by
  624.     bisecting the three sides and connecting the midpoints).  The corners of
  625.     the new triangles are then shifted in space, and they are recursively
  626.     subdivided in turn, to the desired level.  The RECUSIONLEVEL sets this
  627.     depth; the higher the depth, the finer the resulting surface, but the
  628.     slower the image will take to compute (on the order of four times with
  629.     each successive level).  Plus larger level values require substantial
  630.     quantities of address space to contain the generated triangle data (on
  631.     the order of thousands of 512-byte memory pages for a level of 7,
  632.     for example... so BE CAREFUL!).
  633.  
  634.     The X Y and ZSCALE values allow you to emphasize distortion differenly in
  635.     the three dimensions (X and Z of 1.0, with Y of 3.0 results in three 
  636.     times as much vertical relief as horizontal, for example).  Values of 0
  637.     for a scale parameter cause the sub-triangles to not move in the 
  638.     indicated dimension (X and Y of 0 will make the resulting surface 
  639.     maintain a triangular silhouette as seen from above).
  640.  
  641.     The FINALTEXTURE value will be assigned as the texture function number
  642.     for each of the sub-triangles (see the description of texture function
  643.     values for objects below).  Basically, this allows you to apply a uniform
  644.     texture to the entire fractal object: a smooth color gradiation, a
  645.     checkerboard, etc.
  646.  
  647.     As mentioned above, to get a good rough fractal surface, you need to
  648.     also define a small number of wave sources.  A good starting point is
  649.     to specify five or six wave sources, whose actual XYZ coordinates are
  650.     scattered about the scene.  Giving them different wavelenghts and
  651.     amplitudes will increase the fluctuation in the surface.  Generally,
  652.     the damping should be small (values of or near 1.0).  The actual manner
  653.     in which the waves are utilized in constructing the sub triangle vertices
  654.     is beyond convenient description; suffice it to say that there is NO
  655.     randomness involved, and that different wave patters will produce
  656.     markedly different fractal surfaces.  Experment.
  657.  
  658.         Define a marble texture
  659. m BVEINCOLOR GVEINCOLOR RVEINCOLOR XSCALE TURBULENCE SQUEEZE
  660.     You can define up to ten marble textures per scene.  This texture
  661.     relies on your having defined at least one wave source, for reasons
  662.     described below.
  663.  
  664.     The marble is modelled as a base substance that has intrusions of a 
  665.     second substance into the base.  The base color is determined by the 
  666.     diffuse coefficients for the object.  The intrusion color is specified 
  667.     in the three VEINCOLOR parameters.  The actual color for the surface of 
  668.     the marble object is a complex blending function of the two starting 
  669.     colors.
  670.  
  671.     The basic formula for making the intrusions (veins) is to start with
  672.     equally spaced vertical layers (spaced along the X axis).  The spacing is
  673.     determined by the XSCALE parameter (good values are from 0.1 to 1).  Then
  674.     turbulence is applied to the layers, deforming them into myriad whorls 
  675.     and streaks, etc.  The amount of turbulence is set by the TURBULENCE 
  676.     parameter (values from 1.0 to 3.0 are nice).  The rough thickness of the
  677.     streaks is determined by the SQUEEZE parameter (which must be an integer
  678.     -- no fractional component).  The value 1 means leave them normal width; 
  679.     2 means twice as thin; 3 means four times as thin; 4 means eight times, 
  680.     etc.  Another way to think of SQUEEZE is that it affects how fast the 
  681.     blending occurs from the base to the vein color.
  682.  
  683.     The turbulence is controlled by (of all things) the wave sources that you
  684.     have defined in the scene.  Unfortunately, the correspondence between a
  685.     particular wave source and a particular turbulent result is almost
  686.     impossible to predict (but it IS possible; there is no randomness
  687.     involved).  All that can really be done is to give guidelines for general
  688.     wave parameter values.  First, four or five wave sources are needed.  The
  689.     wave centers should be well distributed around the scene. The wavelengths
  690.     should vary amongst the source a good amount (some should be five or six
  691.     times the wavelength of other sources).  Not much damping should be 
  692.     applied (values from 1.0 down to 0.95 perhaps).
  693.  
  694.         Define a wood texture
  695. d BCOLOR GCOLOR RCOLOR THICKSCALE RINGSCALE TURBULENCE SQUEEZE
  696.     You can define up to ten wood textures per scene.  This texture
  697.     relies on your having defined at least one wave source, just like for
  698.     the marble textures listed above.  In fact, at this time wood is modelled
  699.     very similarly to marble, except that where marble consists of parallel
  700.     layers of base material, wood consists of concentric cylinders of base
  701.     material (aligned along the Y axis).  The RINGSCALE parameter is
  702.     analogous to XSCALE for marble; TURBULENCE and SQUEEZE are the same.
  703.     THICKSCALE basically controls how faint or strong the grain is rendered;
  704.     values above 1.0 enhance the grain; values less than 1.0 subdue the 
  705.     grain.
  706.  
  707.  
  708.         Set the eye (camera) view parameters
  709. e XPOS YPOS ZPOS  XVIEW YVIEW ZVIEW  XUP YUP ZUP
  710.     First triple sets the position of the eyepoint.  Second triple
  711.     defines the direction (relative to that point) that the eye will
  712.     look along to define what is visible.  The length of this vector
  713.     determines the "wide-andle vs. telephoto" effect.  To guage what
  714.     different lengths mean, at the tip of the VIEW vector the screen is
  715.     projected as if it were 256 units horizontally by 170 units
  716.     vertically.  Thus the magnitude of the numbers you choose for XYZ
  717.     points interact with the view vector length to determine the cone
  718.     of visibility.  The third triple is the direction you want to be
  719.     "up"; usually 0 1 0 is what you want.
  720.  
  721.         Define a directional light source
  722. l BLUE GREEN RED  XDIR YDIR ZDIR
  723.     The first triple is the color and intesity of the light (1 1 1 would
  724.     be bright white; 0.5 0 0.5 would be dim magenta).  The second triple
  725.     is the direction from which the light is comming.  For example 1 0 0
  726.     would mean the light is comming in straight along the X axis (from
  727.     positive to negative).  You can have at most 100 light sources per
  728.     scene (many light sources sloooows things down -- two is
  729.     reasonable!).
  730.  
  731.         Define a spherical light source
  732. l BLUE GREEN RED  XCENTER YCENTER ZCENTER  DISTANCESCALE  RADIUS
  733.     The first triple is the color and base intensity of the light, just as
  734.     for directional light sources.  The second triple is the XYZ coordionate
  735.     of the center of the spherical light source; it can be anywhere inside
  736.     or outside of the visible scene.  (Note that if the center is within the
  737.     scene, it is not a visible object per-se.  For example, if you wanted a
  738.     lightbulb, you would place the spherical light source where you wanted
  739.     it, and also place a transparent sphere at the same coordinates and with
  740.     the same radius.)  The DISTANCESCALE relates to the inverse-square law
  741.     with which the brightness of the light diminishes within the scene.  To
  742.     explain how to set a value for DISTSCALE, consider the following example.
  743.     Say you wanted a full-intensity white lightbulb (i.e. its nominal BGR
  744.     values would be 1 1 1) to shine onto a table.  If the table were, say,
  745.     37 units of distance from the light coordinate, then you'd want to set
  746.     DISTSCALE to 37 in order that the table would be fully illuminated. Thus,
  747.     objects closer to the light that 37 would appear very bright (indeed,
  748.     probably "overexposed") while objects farther than 37 units from the 
  749.     light would become increasingly dimly lit.  RADIUS is the radius of the
  750.     light emitting sphere; 0.0 would be a point light source.  (Note that 
  751.     point light sources are faster to compute.)  Also note that non-zero 
  752.     radius light sources cast penumbral shadows, though to be effective you
  753.     will need to increase the antialias parameters defined by the "A" 
  754.     command.
  755.  
  756. Now for the actual objects that compose a scene.  You can about thousand
  757. objects max per scene.  All objects have the same basic properties available
  758. to them.  Specifically, the first portion of the command line for any
  759. object starts with:
  760.  
  761. @ TEX FUZZ MIRROR IDX TRA_B TRA_G TRA_R  AMB_B AMB_G AMB_R  DIF_B DIF_G DIF_R
  762.     "@" is the object command character (s,q,x,t,r).
  763.  
  764.     TEX is an integer value that specified what texture function should be
  765.     applied to this object.  Value 0 means no texture (plain, boring evenly
  766.     colored flat surface).  Positive values select from among the supported
  767.     texture functions, as follows:
  768.  
  769.     Value    Texture function
  770.     -----    ----------------
  771.     1:     Y axis color gradiation
  772.         Compute the color at each point on the surface as a function
  773.         of the point's Y coordinate.  Starting at Y=0, the color
  774.         belnds from red to blue to green and back to red at Y=20.
  775.         The colors repeat evern 20 units in Y.
  776.  
  777.     3:     Mottled diffuse
  778.         The brightness of the surface of the object varies to
  779.         form a mottled pattern.  This texture requires some wave
  780.         sources to be defined.
  781.  
  782.     4:    Wavy surface
  783.         The surface will be rendered as being criss-crossed by
  784.         overlapping waves.  If reflectivity is turned on for the
  785.         object, the reflections will be rippled, etc.
  786.  
  787.     5:    Brick pattern
  788.         The object will be rendered as if it were carved out of
  789.         bricks.  The brick size is currently hardwired to be
  790.         height=3.0, width=8.0, depth=4.0, mortar thickness=0.5.
  791.         The color of the bricks is determined by the diffuse
  792.         coefficients for the object; the color of the mortar is
  793.         hardwired at BLUE=0.8, GREEN=0.85, RED=0.99.  The bricks are
  794.         aligned with the coordinate system.
  795.  
  796.     10..19:    Single Wave
  797.         This is like texture 4, except that the surface is rippled
  798.         by only one wave (rather than all of them with texture 4).
  799.         Texture 10 means use the first wave, texture 11 means use
  800.         the second wave, etc. up to 19 for the tenth wave.
  801.  
  802.     20..29:    Marble
  803.         Render the object as if it were carved out of marble.  The
  804.         marble texture chosen depends on the texture number: texture
  805.         20 uses the first marble defined, texture 21 uses the second
  806.         marble defined, etc.
  807.  
  808.     40..49:    Wood
  809.         Render the object as if it were carved out of wood.  The
  810.         wood texture chosen depends on the texture number: texture
  811.         20 uses the first wood defined, texture 21 uses the second
  812.         wood defined, etc.
  813.  
  814.     50..59:    Checkered
  815.         Color the surface of the object according the the chosen
  816.         checkerboard texture.  Texture 50 uses the first defined
  817.         checker pattern, etc.
  818.  
  819.     60..69:    Fractal
  820.         This isn't a texture per se (in so far as most other textures
  821.         operate by changing the color of surface points of the 
  822.                 object).  This texture determines what fractal surface 
  823.                 contours should be applied to this object.  This texture type 
  824.                 may only be specified for object type X (fractal objects). 
  825.                 Texture 6 uses the first defined fractal type, etc.
  826.  
  827.     70..79:    Smooth blend
  828.         Render the surface of the object as a blend between the
  829.         objects normal diffuse color, and the specified blend texture
  830.         color.  Texture 70 uses the first defined blend texture, etc.
  831.  
  832.     80..89:    Snow
  833.         Color the surface of the object by applying the chosen 
  834.             snowfall texture.  Texture 80 uses the first defined snow 
  835.                 texture, etc.
  836.  
  837.     FUZZ is a pseudo-texture factor 0 to 1 that applies a random fuzz to
  838.     the surface of the object.  This can be used in a number of ways: to
  839.     model soft surfaces like tennis balls; to form imperfectly reflecting
  840.     mirrors, to form translucent (etched) glass, etc.
  841.  
  842.     MIRROR is a 0 to 1 value where 0 means no specular and mirror
  843.     reflection, and 1 means 100% specular & mirror reflection.
  844.  
  845.     IDX is the index of refraction for the object.  This is only relevant if
  846.     the transparency for the object is non-zero.
  847.  
  848.     TRA_B, _G, _R is the transparency of the object in each color band.
  849.     0 means opaque, 1 means 100% transparent.
  850.  
  851.     AMB_B, _G, _R is the ambient light value for the object, 0 to 1.  0
  852.     means no pseudo-ambient light, 1 means VERY strong ambient light
  853.     (generally not useful so strong -- washes the object out).
  854.  
  855.     DIF_B, _G, _R is the diffuse reflection values 0 to 1 for the object
  856.     in the color bands.  For example, glass has virtually zero diffuse
  857.     reflection, while chaulk has very high (near 1) diffuse reflection.
  858.     The diffuse coefficients determine the color of the object (in 
  859.     conjunction with the color of the light sources).
  860.  
  861. From the above, notice that non-rational objects can be created.  For
  862. example, a ball that is 100% transparent AND 100% reflective.
  863.  
  864. Now onto each object.  The parameters below FOLLOW (appear to the right
  865. of) all of the above property parameters.
  866.  
  867. s CENTERX CENTERY CENTERZ  RADIUS
  868.     Sphere.  Self-explanetory.
  869.  
  870. q POSX POSY POSZ  VE_X VE_Y VE_Z  VP_X VP_Y VP_Z
  871.     Parallelogram.
  872.     The position triple defines a corner of the parallelogram.  The
  873.     second and third triple are two vectors that define the two sides of
  874.     the object adjacent to and relative to the defining point.  Here's
  875.     the hard part: the order of the two vectors matters.  To try to put
  876.     it simply, the VE vector is the one on the left when viewed from
  877.     "above," and the VP vector is the one on the right.  In another way,
  878.     the VP vector is clockwise from the VE vector.  If the two vectors
  879.     are reversed, the object will appear invisble.  So you may have to
  880.     experiment by reversing them.  Note that the two vectors do not have
  881.     to be orthogonal.
  882.  
  883. t POSX POSY POSZ  VE_X VE_Y VE_Z  VP_X VP_Y VP_Z
  884.     Triangle.
  885.     Same as for a parallelegram, except that the VE, VP vectors define
  886.     the two sides of the triangle.
  887.  
  888. x POSX POSY POSZ  POS1X POS1Y POS1Z  POS2X POS2Y POS2Z
  889.     Fractal.
  890.     This is very much like a triangle, except that whereas the second and
  891.     third set of XYZ values for triangles are relative to the base position
  892.     of the triangle, for a fractal object all three XYZ triples are absolute
  893.     object space positions.
  894.  
  895. r CENTERX CENTERY CENTERZ VE_X VE_Y VE_Z  VP_X VP_Y VP_Z  MINRAD MAXRAD
  896.     Ring (or annullus).
  897.     Rings are sort of like parallelograms.  The first triple defines the
  898.     center of the ring.  The VE and VP triples radiate from that point
  899.     and define the plane of the ring.  It is undefined as to what
  900.     happens if the two vectors are not orthogonal.  MINRAD is the inside
  901.     radius of the ring (which may be zero, forming a disk); MAXRAD is
  902.     the outside radius of the ring.
  903.  
  904. The { and } command lines may be placed around any arbitrary set of
  905. object command lines.  This allows RENDER to do optimized ray tracing by
  906. calculating extent spheres around the indicated primitive objects and
  907. then checking ray intersections with the extent sphere rather than
  908. one-by-one with all the inner objects.  Extents may be nested.
  909.  
  910.  Source file information
  911.  ~~~~~~ ~~~~ ~~~~~~~~~~~
  912. Each program is kept in its own source file directory:
  913.  
  914.     ray_source/
  915.         makefile
  916.         ray.h    - all global definitaions
  917.         ray.c    - main module of ray tracer
  918.         val.c    - current intensity value of an object
  919.         hit.c    - calculate if an object gets hit by a ray
  920.         tex.c    - calculate the texture of an object
  921.         ext.c    - handle extents ({,} commands)
  922.         rnd.c    - random number table
  923.         mth.c    - perform vector and matrix math
  924.         fil.c    - file i/o
  925.         int.c    - find intersections with objects
  926.         cal.c    - top level object calculations
  927.     ray2_source/
  928.         makefile
  929.         ray2.c    - source for post-processor
  930.     display_source/
  931.         makefile
  932.         display.c - source for display package
  933.  
  934.