home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / graphic / qrt / userman.doc < prev    next >
Text File  |  1989-03-26  |  43KB  |  1,453 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.         
  9.                                 QRT Users Manual
  10.         
  11.         INTRODUCTION
  12.            
  13.            QRT (Quick Ray Tracer) is  an  easy  to  use  image generation
  14.            system that uses a ray tracing algorithm  for image rendering.
  15.            Versions exist for  the  Amiga  personal  computer,  the  Data
  16.            General MV10000, the HP  9000  series,  and  the  IBM AT.  QRT
  17.            overcomes many of the problems of  other ray tracing packages,
  18.            and  is  designed  to   operate   nicely  in  a  multi-tasking
  19.            environment.
  20.            
  21.            
  22.         COMPARISON TO OTHER SYSTEMS
  23.            
  24.            QRT was developed on the Amiga  personal  computer, so it will
  25.            be compared to  other  Amiga  ray  tracers.  There  are, to my
  26.            knowledge, five other  Amiga  ray  tracers,  each with its own
  27.            strengths  and  weaknesses.    I  will  describe  each  system
  28.            briefly, and compare it to QRT.  All the Amiga ray tracers can
  29.            operate in HAM (4096 color) mode.
  30.            
  31.               RT: RT was the first ray  tracer  written for the Amiga, by
  32.                   Eric    Graham.  It will model  a universe made of only
  33.                   spheres, a   sky, and a checkered  or solid ground.  It
  34.                   is  relatively  fast,  but  not  generally  useful  for
  35.                   realistic modeling   because  of the sphere limitation.
  36.                   The input language  is  cryptic,  although  some  error
  37.                   checking is done.  The  system  will  only generate low
  38.                   resolution images.
  39.            
  40.              SILVER: I have never seen SILVER, so I cannot say much about
  41.                   this system.
  42.            
  43.              SCULPT-4D: This package  incorporates  an interactive editor
  44.                   for  creating  objects,   and  is  capable  of  quickly
  45.                   generating a preliminary  image  of  the scene by using
  46.                   hidden surface techniques.  However, every primitive is
  47.                   made of polygons, and some  primitives  such as spheres
  48.                   require hundreds of  polygons  for a smooth texture, so
  49.                   the ray tracing is very slow.   Also, the package takes
  50.                   a large amount of memory to run, and is prone to system
  51.                   crashes.  Its chief  feature  is  the ability to create
  52.                   arbitrary shaped objects  using  a series of triangles.
  53.                   Mirrored, dull, or shiny objects are supported.
  54.            
  55.              CLIGHT: This ray tracer also has  an interactive editor, but
  56.                   produces very poor quality  images.   It is not capable
  57.                   of any patterning or reflection characteristics.
  58.  
  59.  
  60.         QRT Ray Tracer               Page 1                   User Manual
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.            
  74.              DBW: This is possibly the most  complete  ray tracer for the
  75.                   Amiga.  It will support objects  with arbitrary degrees
  76.                   of reflection and gloss,  depth  of field effects, some
  77.                   texturing,   wavy   surfaces,   fractals,   transparent
  78.                   surfaces, diffuse  propagation  of light from object to
  79.                   object,  and  5  primitive   types  (sphere,  triangle,
  80.                   parallelogram, fractal, and ring).  The input language,
  81.                   however,   is    so    cryptic    as   to   be   nearly
  82.                   incomprehensible, and  if  there  is  any  error in the
  83.                   input file,  it  will  crash  the  system.   It is also
  84.                   painfully slow;  some  images  take  16  to 24 hours to
  85.                   complete.
  86.            
  87.            QRT is meant to be a  compromise  between the fast, simple ray
  88.            tracers and the slow powerful systems.   It compares favorably
  89.            in speed to RT, and in power  to  Sculpt-3d  or DBW.  It has a
  90.            very friendly input language  with  extensive  error checking.
  91.            Here are some features of QRT:
  92.            
  93.                o   Multiple  primitive   types,  including  user  defined
  94.                   quadratic       surfaces
  95.            
  96.                o  Arbitrary  levels  of   diffuse   reflection,  spectral
  97.                   reflection, transmission, ambient lighting, and gloss
  98.            
  99.                o  User defined pattern information for objects
  100.            
  101.                o  Bounding boxes for groups of objects
  102.            
  103.                o  Shadows
  104.            
  105.                o  Multiple light sources with different characteristics
  106.            
  107.                o  Arbitrary Phong spectral reflection coefficients
  108.            
  109.                o  Color dithering  to  increase  the  apparent  number of
  110.                   colors
  111.            
  112.                o  Easy to use, free  format  input  language  with  error
  113.                   checking.  Parameters are by  keyword and may appear in
  114.                   any   order.
  115.            
  116.                o  Supports medium resolution (128k dots/screen)
  117.            
  118.            Each of these features of  QRT  will  be  discussed is greater
  119.            detail in this document.
  120.            
  121.  
  122.  
  123.  
  124.  
  125.  
  126.         QRT Ray Tracer               Page 2                   User Manual
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.         THE QRT WORLD
  140.         
  141.         QRT constructs an  image  of  the  world  by  performing  certain
  142.         manipulations  on  an  internal  representation  of  a  group  of
  143.         objects.  You must provide a description  of these objects to QRT
  144.         through the QRT input language.
  145.         
  146.         QRT writes a machine independent bitmap file which can be read by 
  147.         a computer specific post  processor.   The  post processor either
  148.         displays the  image  or  converts  it  into  the  proper form for
  149.         display  by  system   programs.     (See  the  Machine  Dependent
  150.         Information section of this manual for details).
  151.         
  152.         QRT is capable of dealing  with  5  types  of  primitive objects:
  153.         spheres,   parallelograms,   triangles,   rings   (annulus),  and
  154.         quadratic  surfaces.   The  latter  can  be  used to model cones,
  155.         oblong spheroids, and other interesting  surfaces.  Each of these
  156.         objects can have an arbitrary orientation in space, and arbitrary
  157.         surface characteristics.
  158.         
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.         QRT Ray Tracer               Page 3                   User Manual
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.         QRT INPUT LANGUAGE
  206.            
  207.            The QRT input language is free format, in that commands may be
  208.            placed anywhere on a line, and  newlines  may be placed at any
  209.            point.  This makes it easy to  use  indentation.  Comments are
  210.            also supported by surrounding  text  with curly braces '{' and
  211.            '}'. Comments may span lines.
  212.            
  213.            Once a file with QRT commands  is  built  (using any available
  214.            text editor), qrt can be made to process these commands:
  215.            
  216.                QRT <commands.qrt
  217.            
  218.            where "commands.qrt" is the  file  containing  the input.  QRT
  219.            also produces  some  statistics,  so  this  output can also be
  220.            redirected. Since QRT runs for a  long time, you will probably
  221.            want to run it as a background task  with a low priority.  So,
  222.            the full set of commands to run QRT would be:
  223.            
  224.                SetTaskPriority -5
  225.                run QRT <commands.qrt >qrt.out
  226.                SetTaskPriority 0
  227.            
  228.            This set of commands is  specific  to the Commodore Amiga; see
  229.            the Machine Dependent  Information  section  of the manual for
  230.            other operating systems.
  231.            
  232.            QRT will write a very large  file,  which may be anywhere from
  233.            400K 
  234.            to 4 megabytes depending  on  the  specific  computer  display
  235.            resolution.  (See the Machine Dependent Information section of
  236.            this manual for the  exact  file  size).   There  should be at
  237.            least enough room on your  disk  to  accommodate this file.  I
  238.            recommend  sending  the  output  to  a  RAM  disk, so that the
  239.            physical disk does  not  get  used  for  60  minutes while QRT
  240.            computes the image.
  241.            
  242.            A typical QRT command  to  create  a  sphere using the default
  243.            surface attributes would, be:
  244.            
  245.                SPHERE ( loc = (5,10,100)     { this is a white sphere }
  246.                         radius = 12.5
  247.                       )
  248.            
  249.            For comparison, the sphere command for DBW looks like this:
  250.            
  251.                s 0 0 0 1 0 0 0 .2 .2 .2 .8 .8 .8 5 10 100 12.5
  252.            
  253.            Or, in RT, the command would be:
  254.            
  255.                <1,1,1> 2 (5,10,100):1;
  256.  
  257.  
  258.         QRT Ray Tracer               Page 4                   User Manual
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.            
  272.            The QRT input should be  much  easier  to  understand.  If QRT
  273.            sees an error in its input  file,  it  will stop and print the
  274.            line number of the offending  line,  along  with a descriptive
  275.            error message (ILLEGAL PARAMETER, etc).
  276.            
  277.            The  QRT  input  language  is  not  case  sensitive.   A  full
  278.            description of  the  language  and  a  shorter,  context  free
  279.            grammar can be found elsewhere in this manual.
  280.            
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.         QRT Ray Tracer               Page 5                   User Manual
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.         THE QRT ILLUMINATION MODEL
  338.            
  339.            Before meaningful images can be  created, the QRT illumination
  340.            model must be understood.  The light that reaches the observer
  341.            from each object is composed of several components:
  342.            
  343.               o Diffuse light       - The "color" of the object
  344.            
  345.               o Ambient light       - The  color  of the light that falls
  346.                                       on                              the
  347.                                       surface of the  object  if no lamps
  348.                                       are shining  on  this  spot.   Note
  349.                                       that this  specifies  the  color of
  350.                                       light, not the color  of the object
  351.                                       itself.
  352.            
  353.               o Reflected light     -  If  the  object  acts as a mirror,
  354.                                       some  light is reflected.
  355.            
  356.               o Specular highlights  -  The  "bright  spots"  of  a shiny
  357.                                       object viewed in a light.
  358.            
  359.               o Transmitted light   - The object may transmit some of the
  360.                                       light that strikes  the back of the
  361.                                       object (glass surfaces)
  362.            
  363.            All of these light  characteristics  can  be specified for any
  364.            object.  If  none  are  specified,  the  current  defaults are
  365.            assumed.  These  defaults  can  be  changed  (see  DEFAULT  in
  366.            Language Reference Guide).
  367.            
  368.            Most of these light characteristics  deal with a percentage of
  369.            light.  For example, a light may  reflect 80% of the red light
  370.            that strikes it, 20% of the green,  and 40% of the blue.  This
  371.            is the "color" of the  object  (diffuse  light),  and would be
  372.            specified in QRT by the following syntax:
  373.            
  374.                          diff = (.80, .20, .40)
  375.            
  376.            In QRT, 1.00 is 100%.  The  language  is  also free-format, so
  377.            the above is equivalent to:
  378.            
  379.                          diff = (.80,
  380.                                  .20,
  381.                                  .40 )
  382.            
  383.            The commas between parameters are optional, but make the input
  384.            easier to read.  Semicolons can also be used.
  385.            
  386.            Ambient light is specified in a similar manner:
  387.            
  388.  
  389.  
  390.         QRT Ray Tracer               Page 6                   User Manual
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.                          amb = (.20, .20, .20)
  404.            
  405.            The ambient light values should  be fairly small.  Most of the
  406.            light hitting the object comes  from  lamps, but some parts of
  407.            the object may be in  the  shadow  of  another  object.  If no
  408.            ambient light is specified, these  shadows will appear totally
  409.            black, which looks  unrealistic.   Ambient light will give the
  410.            affect of a small amount of  light  hitting areas in a shadow,
  411.            producing a more realistic looking image.
  412.            
  413.            Reflection is specified using the MIRROR attribute:
  414.            
  415.                          mirror = (.90, .90, .90)
  416.            
  417.            If a true  mirrored  surface  is  desired,  the  mirror values
  418.            should be fairly high.   If  one  of  the  values has a higher
  419.            value than the others, the  mirror  will appear red, green, or
  420.            blue.
  421.            
  422.            Transmission is specified as follows:
  423.            
  424.                          trans   = (.80, .80, .80)
  425.                          density = (.022, .022, .022)
  426.                          index = 1.33
  427.            
  428.            Note  the  addition  of   another   parameter,  the  index  of
  429.            refraction. An explanation of  the  index of refraction for an
  430.            object is beyond the scope of  this  document  - see a book on
  431.            elementary optics for details.   The density factor is a light
  432.            attenuation factor per unit distance the light travels through
  433.            the object.  The trans  parameter  tells QRT how much light to
  434.            remove from shadows cast by 
  435.            this object.
  436.            
  437.            In  addition,  specular  highlights  are  specified  with  two
  438.            parameters:
  439.            
  440.                          reflect  = .50,
  441.                          sreflect = 45
  442.            
  443.            "REFLECT" is the percentage of light reflected in the specular
  444.            highlight, and  sreflect  is  the  Phong  spectral  reflection
  445.            coefficient.  Again, an  explanation  of the Phong coefficient
  446.            is beyond the scope of this document;  however, a higher value
  447.            for the coefficient will result in smaller, tighter highlights
  448.            for a more metallic looking object.   Lower values of sreflect
  449.            should be accompanied  by  lower  values  in reflect, and will
  450.            produce duller looking surfaces, such as paper.
  451.            
  452.            QRT also accepts a dithering amount for each object:
  453.            
  454.  
  455.  
  456.         QRT Ray Tracer               Page 7                   User Manual
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.                          dither = 3
  470.            
  471.            Dithering is a mechanism for  simulating  colors not available
  472.            on  the  display  by  blending   other  colors.   The  default
  473.            dithering coefficient is 3; it  should  be kept small.  Values
  474.            of 1 to  6  are  good.   Larger  objects  should  employ  more
  475.            dithering, and mirrored or glass objects should have little or
  476.            no dithering.
  477.            
  478.            QRT also accepts an attribute "FUZZ",  but this is not used in
  479.            the present  implementation.   In  a  future implementation of
  480.            QRT, FUZZ will  effect  small,  random  perturbations  of  the
  481.            normal vector at a  given  location  on  an object.  This will
  482.            simulate  rough  surfaces,   matted   glass,   or  imperfectly
  483.            reflecting mirrors.
  484.            
  485.            All of the above light characteristics  may be attached to any
  486.            object.  The default  is  for  a  white,  non  reflecting, non
  487.            transmitting dull surface with an average amount of dithering.
  488.            In addition, any of the above color information (which will be
  489.            referred to from now on as COLORINFO)  may also be attached to
  490.            a  pattern  structure   (see   the  PATTERN  section  of  this
  491.            document).
  492.            
  493.  
  494.  
  495.  
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
  513.  
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.         QRT Ray Tracer               Page 8                   User Manual
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.         LIGHT SOURCES
  536.            
  537.            Light sources in QRT are  called  "LAMPS".  The lamp structure
  538.            is simple:
  539.            
  540.                         LAMP ( loc = (12, 34, 56),
  541.                                dist = 50,
  542.                                radius = 10 )
  543.            
  544.            The default is for a  bright  white  lamp,  but if you wish to
  545.            change this, you can specify  different  values for the lamp's
  546.            ambient  light.    The   radius   value  is  ignored  by  this
  547.            implementation of QRT, but it  must  be supplied.  In a future
  548.            version,  the  radius  may  be  used  to  implement  penumbral
  549.            shadows.  I didn't include  them  in  this version, since they
  550.            take a very long time to  compute,  and  don't add much to the
  551.            image quality.
  552.            
  553.            The "dist" entry in  the  lamp  structure  specifies  at  what
  554.            distance the light from the lamp is at full intensity.  Beyond
  555.            this value, the light will decrease  in intensity.  This value
  556.            should be set so  that  the  nearest  object  in  the scene is
  557.            slightly more than "dist" distance  units from the lamp.  This
  558.            does not have to be exact. If  objects  are  nearer than dist"
  559.            units, they will  be  so  bright  that  shading  will not take
  560.            place. Objects very far away will be dimly illuminated.
  561.            
  562.            By the way, QRT distance units are  not tied to any real world
  563.            unit.  They can stand for  feet,  nautical miles, or furlongs,
  564.            at your choice.
  565.            
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.         QRT Ray Tracer               Page 9                   User Manual
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.         THE OBSERVER
  602.            
  603.            After defining the world, you  must  tell QRT the position and
  604.            orientation of the observer.  This is done as follows:
  605.            
  606.                     OBSERVER ( loc     = (0, 10,  20),
  607.                                lookat  = (5,  5, 120),
  608.                                up      = (0,  1,   0)
  609.                              )
  610.            
  611.            The x,y, and z are the location of the observer.  The "lookat"
  612.            variables give  a  location  in  space  that  the  observer is
  613.            looking at.  Most ray tracers  require  you to give two angles
  614.            for the observers  view  direction,  but  it is MUCH easier to
  615.            know the location of an object or  point in space you wish the
  616.            observer to look at.  This will be the center of your scene.
  617.            
  618.            The "up" variables define which direction is up.  Usually, you
  619.            will wish to use the  values  given  above.   QRT uses a right
  620.            hand coordinate system: positive y is up, positive z is out of
  621.            the screen, and positive x is to  the right if you are looking
  622.            in the negative z direction.  The  "up" parameter is optional,
  623.            and if omitted, defaults to (0,1,0).
  624.            
  625.            QRT will generate an error message if no observer is defined.
  626.            
  627.  
  628.  
  629.  
  630.  
  631.  
  632.  
  633.  
  634.  
  635.  
  636.  
  637.  
  638.  
  639.  
  640.  
  641.  
  642.  
  643.  
  644.  
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651.  
  652.  
  653.  
  654.         QRT Ray Tracer               Page 10                  User Manual
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.         OUTPUT FILENAME
  668.            
  669.            QRT places its output in a file,  so you must give it the name
  670.            of this file:
  671.            
  672.                          FILE_NAME = outfile.tmp
  673.            
  674.            This file must observe  any  file  naming  restrictions of the
  675.            operating system and computer you  are using.  See the Machine
  676.            Dependent Information section  of  this manual for information
  677.            on file naming restrictions.
  678.            
  679.            
  680.            
  681.         FOCAL LENGTH
  682.            
  683.            This is the focal length of  the  "lens" used by the observer.
  684.            Think of it as a 35mm camera  lens  - higher numbers produce a
  685.            telephoto  effect,  and  smaller  numbers  are  for wide angle
  686.            lenses. Note that small numbers may produce some distortion of
  687.            the  image around the edges.
  688.            
  689.                          FOC_LENGTH = 60
  690.            
  691.  
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.         QRT Ray Tracer               Page 11                  User Manual
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.         SKY AND GROUND
  734.            
  735.            QRT has facilities  for  generating  the  sky  and ground.  To
  736.            define the sky, you must give it  two colors - one for the sky
  737.            overhead (zenith), and one for the horizon:
  738.            
  739.                          SKY ( zenith  = (.10, .2, .4),
  740.                                horiz   = (.10, .2, .65),
  741.                                dither   = 6
  742.                          )
  743.            
  744.            This will produce a blue sky,  with  a brighter color near the
  745.            horizon.  (The sky need not be  blue  - it could be red or hot
  746.            pink, or vary from red to green).  QRT will smoothly blend the
  747.            colors from the zenith to the  horizon.   Since  the sky is so
  748.            large, you may want to specify  a  greater amount of dithering
  749.            to compensate for the displays color resolution limit.
  750.            
  751.            The SKY structure  will  also  produce  sky  colors  below the
  752.            horizon; any ray that does  not  strike  an object will strike
  753.            the SKY.  To fix this, define a ground.  There is no dedicated
  754.            GROUND   command,   since   you   can   define  a  very  large
  755.            parallelogram with the  same  effect.   You  can make it brown
  756.            with patches of green using a PATTERN,  or checkered green and
  757.            yellow in the  classic  ray-tracing  ground  pattern.   A very
  758.            large sphere can also be  used  for  the  ground, which yields
  759.            better results with mirrored objects.
  760.            
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.         QRT Ray Tracer               Page 12                  User Manual
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796.  
  797.  
  798.  
  799.         BOUNDING BOXES
  800.            
  801.            QRT supports the  use  of  bounding  boxes  to  speed  the ray
  802.            tracing process.  For images  composed  of only a few (1 to 3)
  803.            objects, bounding boxes will  not  do  much to increase speed.
  804.            However,  for  images  where   there  are  groups  of  objects
  805.            physically close  to  each  other,  they  can  greatly  reduce
  806.            execution times.  A  bounding  box  is  a conceptual structure
  807.            that encloses a group  of  objects.   When  the  ray tracer is
  808.            finding line/object intersections, if a line does not strike a
  809.            bounding box, it  cannot  possibly  strike  any objects within
  810.            that bounding box.  This saves  the  ray tracer the trouble of
  811.            checking intersections with  all  objects  within the box.  In
  812.            the case where the ray  DOES  enter  the  box, some additional
  813.            overhead is incurred; however,  this  cost is easily justified
  814.            by reduced times for negative tests.
  815.            
  816.            Bounding boxes can occasionally be useful for complex objects,
  817.            such as quadratic surfaces,  when  the object is fairly small.
  818.            Since the time to  find  the  intersection  with  a  quadratic
  819.            surface is large, but bounding box intersections are fast, the
  820.            ray tracer can save time for all the negative tests.
  821.            
  822.            Bounding  boxes  can  contain   other  bounding  boxes,  in  a
  823.            recursive manner.  This recursive structure defines an "object
  824.            tree". There are two keywords  that  define  the beginning and
  825.            end of a bounding box:  BEGIN_BBOX  and  END_BBOX.  Here is an
  826.            example:
  827.            
  828.            
  829.                { ** QRT Code for a chessman ** }
  830.            
  831.                BEGIN_BBOX
  832.            
  833.                    QUADRATIC (  { ** quadr defn ** }
  834.                              )
  835.            
  836.                    QUADRATIC (  { ** quadr defn 2 ** }
  837.                              )
  838.            
  839.                    SPHERE    (  { ** sphere defn ** }
  840.                              )
  841.            
  842.                    BEGIN_BBOX
  843.            
  844.                        SPHERE ( )    { ** two spheres ** }
  845.                        SPHERE ( )
  846.            
  847.                    END_BBOX
  848.            
  849.                END_BBOX
  850.  
  851.  
  852.         QRT Ray Tracer               Page 13                  User Manual
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862.  
  863.  
  864.  
  865.            
  866.            This structure may be nested to an arbitrary level; if you had
  867.            a closely spaced group of  chessmen,  you could enclose all of
  868.            them with a bounding box.
  869.            
  870.            There is no simple  algorithm  for  knowing  exactly  where to
  871.            place  bounding  boxes.    You   have  to  use  common  sense.
  872.            Typically, bounding boxes do the  most good for closely spaced
  873.            objects, but if the  entire  group  of  objects is less than a
  874.            third of the image area, it will be useful to enclose them all
  875.            in a bounding box.
  876.            
  877.  
  878.  
  879.  
  880.  
  881.  
  882.  
  883.  
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892.  
  893.  
  894.  
  895.  
  896.  
  897.  
  898.  
  899.  
  900.  
  901.  
  902.  
  903.  
  904.  
  905.  
  906.  
  907.  
  908.  
  909.  
  910.  
  911.  
  912.  
  913.  
  914.  
  915.  
  916.  
  917.  
  918.         QRT Ray Tracer               Page 14                  User Manual
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928.  
  929.  
  930.  
  931.         PATTERNS
  932.            
  933.            QRT permits user defined  patterns  which can be mapped to the
  934.            surface of any object.  A  pattern  is  basically an organized
  935.            method for changing an object's  COLORINFO over the surface of
  936.            that object.  For example, a checkered surface can be created,
  937.            or a surface  given  the  appearance  of  brick  or tile.  The
  938.            current patterning in QRT is  limited,  yet powerful enough to
  939.            describe many common patterns.
  940.            
  941.            A pattern is composed  of  a  series  of  sub-patterns.   Each
  942.            sub-pattern defines a region on the surface of an object which
  943.            will contain a given  COLORINFO.   These regions are presently
  944.            limited to rectangles, but  this  may  be expanded in a future
  945.            implementation of QRT.
  946.            
  947.            A pattern can be defined once, and used for many objects.  For
  948.            example, a brick pattern might be defined:
  949.            
  950.            
  951.                      PATTERN ( name = BRICK,
  952.                                { ** other pattern info here ** }
  953.                              )
  954.            
  955.                      SPHERE  ( { ** sphere definition ** }
  956.                                pattern = BRICK
  957.                              )
  958.            
  959.                      PARALLELOGRAM ( { ** parallelogram definition ** }
  960.                                      pattern = BRICK
  961.                                    )
  962.            
  963.            This  example  ignores   what   is  actually  in  the  pattern
  964.            definition  to  demonstrate   how  patterns  are  attached  to
  965.            objects.  A pattern must be defined before it can be used.  It
  966.            is given a name, such  as  BRICK,  and  any object can specify
  967.            this pattern with "PATTERN =  BRICK".   There are no practical
  968.            restrictions on the length of pattern  names (if your computer
  969.            has 1 megabyte of ram, you  cannot  have a pattern name longer
  970.            than 1 million characters).  Multiple  patterns may be defined
  971.            at the top of an input file,  and  used  for any object in the
  972.            file.
  973.            
  974.            What exactly makes up a  pattern,  you  ask?  A pattern can be
  975.            viewed as a rectangle that is repeated  over the surface of an
  976.            object.  If the  pattern  size  is  10  x  10, and you have an
  977.            object (say a parallelogram) that is 50 x 50, the pattern will
  978.            repeat 5 times  in  each  direction.   Within  this  repeating
  979.            rectangle, sub patterns can  be  defined.   A sub-pattern is a
  980.            rectangle or  circle  within  the  pattern  rectangle  with  a
  981.            certain COLORINFO. Any  number  of  these  sub-patterns can be
  982.  
  983.  
  984.         QRT Ray Tracer               Page 15                  User Manual
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994.  
  995.  
  996.  
  997.            created within one pattern definition. To create a brick wall,
  998.            you might define several  sub-patterns,  each  with a slightly
  999.            different color of red or  brown.   The  sub patterns need not
  1000.            cover the  entire  pattern  rectangle;  if  they  do  not, the
  1001.            COLORINFO you defined for the  object  is  used instead of the
  1002.            pattern COLORINFO.  If you  defined  sub-patterns  for bricks,
  1003.            the  area  not  covered  would  be  mortar,  and  the  objects
  1004.            COLORINFO would define  the  color  of  the  mortar. An actual
  1005.            brick pattern is  given  in  appendix  C.   The  proper use of
  1006.            patterns can be very effective in  producing realistic looking
  1007.            scenes.   However,   complicated   patterns  will  slow  image
  1008.            creation, so it  is  recommended  that  you first display test
  1009.            scenes with no patterns, and then add pattern information when
  1010.            the scene is right.
  1011.            
  1012.            Patterns have one other use, in the REMOVE command.  A pattern
  1013.            can be defined and thought  of  as  a  cut out from a surface.
  1014.            For example, suppose you wish  to  make  a flat surface in the
  1015.            shape of a grand piano top.   Rather  than  creating the piano
  1016.            top out of many parallelograms and triangles, define a pattern
  1017.            that includes 
  1018.            everything in a parallelogram  but  NOT in the piano top; that
  1019.            is, the pattern maps the area to remove, not the area to keep.
  1020.            Attach this  pattern  to  a  planar  object  with  the  REMOVE
  1021.            command.   In  this  case,  since  the  area  is  removed, any
  1022.            associated COLORINFO is ignored.
  1023.            
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.         QRT Ray Tracer               Page 16                  User Manual
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060.  
  1061.  
  1062.  
  1063.         INSTANCES
  1064.            
  1065.            Often, several copies of  a  complex  object  must be created.
  1066.            Specifying  their  component  primitives  each  time  would be
  1067.            difficult.  There  is  a  solution  to  both  these  problems:
  1068.            INSTANCES.   An  INSTANCE   is   a  method  by  which  several
  1069.            primitives (actually, an arbitrary object tree) can be grouped
  1070.            and given a name.   Copies  of  these  objects  may  be easily
  1071.            created with one command.   Here  is an example of an instance
  1072.            definition.
  1073.            
  1074.                    BEGIN_INSTANCES
  1075.            
  1076.                        NAME = object1
  1077.                        BEGIN_BBOX
  1078.                            { ** a bunch of primitives here ** }
  1079.                        END_BBOX
  1080.            
  1081.                        NAME = object2
  1082.                        BEGIN_BBOX
  1083.                            { ** a bunch more primitives  here ** }
  1084.            
  1085.                            NAME = spheres
  1086.                            BEGIN_BBOX
  1087.                              SPHERE ( )  { ** two sphere definitions ** }
  1088.                              SPHERE ( )
  1089.                            END_BBOX
  1090.            
  1091.                        END_BBOX
  1092.            
  1093.                    END_INSTANCES
  1094.            
  1095.            There can be only one of  these  instance  definitions, and it
  1096.            must appear  before  any  instances  are  used.   However, any
  1097.            arbitrary object tree can appear within the begin/end instance
  1098.            statements. Several instances are  now available for use.  For
  1099.            example:
  1100.            
  1101.                    INSTANCE_OF (  name = object1,
  1102.                                   loc  = (100, 10, 20),
  1103.                                )
  1104.            
  1105.                    INSTANCE_OF (  name = spheres,
  1106.                                   loc  = (12.3, 24.5, 999)
  1107.                                )
  1108.            
  1109.            This example shows  that  any  named  portion  of  the  object
  1110.            subtree can function as an  instance  (the "spheres" object is
  1111.            at a lower level than  the  "object1'  object).   The "offset"
  1112.            parameters are required.  They specify  a new position for the
  1113.            instance (offset from the origin).  In the instance definition
  1114.  
  1115.  
  1116.         QRT Ray Tracer               Page 17                  User Manual
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126.  
  1127.  
  1128.  
  1129.            segment, all objects are defined  relative to 0,0,0.  They can
  1130.            then be moved in  the  INSTANCE_OF  statement  with the offset
  1131.            command.
  1132.            
  1133.            In addition, the instance can be given a new size:
  1134.            
  1135.                    INSTANCE_OF (  name    = object2,
  1136.            
  1137.                                   loc     = (200, 100, 50),
  1138.                                   scale   = (1.5, 2.0, .25)
  1139.                                )
  1140.            
  1141.            The scale factors are  optional,  and are given the default of
  1142.            1. The instance will  be  resized  by  the indicated amount in
  1143.            each of the directions.  Note that there are some restrictions
  1144.            to this: if spheres are given a different scale factor in each
  1145.            direction, they will remain  spheres  (not change to QUADRATIC
  1146.            types).  The new radius will  be  the old radius scaled by the
  1147.            smallest of the scale factors.
  1148.            
  1149.  
  1150.  
  1151.  
  1152.  
  1153.  
  1154.  
  1155.  
  1156.  
  1157.  
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.  
  1164.  
  1165.  
  1166.  
  1167.  
  1168.  
  1169.  
  1170.  
  1171.  
  1172.  
  1173.  
  1174.  
  1175.  
  1176.  
  1177.  
  1178.  
  1179.  
  1180.  
  1181.  
  1182.         QRT Ray Tracer               Page 18                  User Manual
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192.  
  1193.  
  1194.  
  1195.         DEFAULTS
  1196.            
  1197.            Each object in QRT is  given  certain  default  surface  light
  1198.            characteristics (see the section  on surface characteristics).
  1199.            If these defaults are not  suitable,  they can be changed with
  1200.            the DEFAULT command:
  1201.            
  1202.                    DEFAULT ( diff = (1.00, .1, .1)
  1203.                              no_shadow )
  1204.            
  1205.            This  will  make  all  future  objects  red  unless  specified
  1206.            otherwise. More than  one  default  command  can  be used in a
  1207.            file: each one affects all the  objects  created after it, but
  1208.            before the next default  command.   Any  light characteristics
  1209.            can be changed (MIRROR, DITHER, etc).
  1210.            
  1211.            In addition,  the  keyword  "no_shadow"  can  be  included (as
  1212.            above). Ordinarily, QRT  computes  shadow  information for all
  1213.            objects. This takes a  lot  of  time,  especially  for  scenes
  1214.            composed of many objects  and  many  lamps.   The  "no_shadow"
  1215.            command causes QRT to bypass  the  shadow routines.  This will
  1216.            result in a much faster image generation time, but the picture
  1217.            will not look as realistic.
  1218.            
  1219.            X and Y screen resolution and aspect ratio can also be changed
  1220.            with this command.  If  you  wish  to  generate  a preliminary
  1221.            image in a smaller resolution,  say,  127 x 127, you would use
  1222.            the following default:
  1223.            
  1224.                    DEFAULT ( x_res  = 127,
  1225.                              y_res  = 127,
  1226.                              aspect = .56
  1227.                            )
  1228.            
  1229.            The aspect ratio of .56 is correct for the Amiga in 4096 color
  1230.            mode; use 1.0 for high resolution mode.
  1231.            
  1232.            
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.         QRT Ray Tracer               Page 19                  User Manual
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258.  
  1259.  
  1260.  
  1261.         PROBLEMS WITH QRT
  1262.            
  1263.            There are several limitations in this version of QRT:
  1264.            
  1265.                o Patterning  does  not  work  well  with  some  quadratic
  1266.                   surfaces.  This is a problem  with the 3d to 2d mapping
  1267.                   function used for quadratics.
  1268.            
  1269.                o  User defined texturing is not implemented - all objects
  1270.                   in  QRT appear smooth.  I have some ideas on how to add
  1271.                   textures to objects, but these have not been tested and
  1272.                   are not incorporated into this version of QRT.
  1273.            
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.         QRT Ray Tracer               Page 20                  User Manual
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.  
  1323.  
  1324.  
  1325.  
  1326.  
  1327.         FUTURE ENHANCEMENTS TO QRT
  1328.            
  1329.            The following are some things I'd like to add to QRT:
  1330.            
  1331.                o  Enhanced  patterning  capability.  The  ability  to use
  1332.                   enumerated (bit-mapped)  patterns  as  well as analytic
  1333.                   patterns would be useful.
  1334.            
  1335.                o  Anti-dithering  routines.   These  routines   are  very
  1336.                   computationally  expensive  (they  can  increase  image
  1337.                   generation times by a  factor  of 3 to 5), so they were
  1338.                   not included in this version.
  1339.            
  1340.                o  Penumbral shadows.  This is  also  very computationally
  1341.                   expensive for a  minimal  utility  level,  so  I didn't
  1342.                   bother to include this feature.
  1343.            
  1344.                o     Fractal    generation.      Fractals   are,   again,
  1345.                   computationally  expensive,  but  some  things, such as
  1346.                   mountains, cannot  be  modeled  with  a  ray tracer any
  1347.                   other way.
  1348.            
  1349.                o  Wavy surfaces.  This  is  useful  for  modeling  water,
  1350.                   rippled mirrors, etc.   I  know  how  to  do it, I just
  1351.                   didn't have time to add it  yet.   It  would be nice if
  1352.                   the waves were user definable  in amplitude and x and y
  1353.                   wavelength.    Wavy   surfaces   are  very  similar  in
  1354.                   implementation to textures.
  1355.            
  1356.                o  Snowy surfaces.  This is an  idea  from DBW, which adds
  1357.                   snow to a surface depending on its slope and altitude.
  1358.            
  1359.                o  Interpolated normal  surfaces.   This is a mechanism to
  1360.                   model arbitrary curved  surfaces  by  using a polygonal
  1361.                   approximation to  the  surface,  and  interpolating the
  1362.                   normal vector between surfaces to avoid angular looking
  1363.                   surfaces.
  1364.            
  1365.                o  Image plane object  lists.    This  is  a technique for
  1366.                   increasing   the   speed   for   positive   line/object
  1367.                   intersection test.  (Bounding  boxes increase speed for
  1368.                   negative line/object intersection tests). 
  1369.            
  1370.                o  Heuristics for faster  completion  of images using area
  1371.                   coherence.
  1372.            
  1373.                o  An interactive  editor.   This  is  another large scale
  1374.                   project in itself, and I can't forsee having time to do
  1375.                   it for a long time, but it would be useful.  The editor
  1376.                   would display  a  preliminary  image  of the scene, and
  1377.                   when the user had placed  objects  to his satisfaction,
  1378.  
  1379.  
  1380.         QRT Ray Tracer               Page 21                  User Manual
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.  
  1389.  
  1390.  
  1391.  
  1392.  
  1393.                   it would write  a  QRT  input  file  and  call QRT as a
  1394.                   background task.  There are certain problems here - for
  1395.                   instance, how do you quickly  generate the outline of a
  1396.                   user defined quadratic that can  take many forms (cone,
  1397.                   spheroid, etc)?  And how  can  the  user easily specify
  1398.                   the object tree  structure  (bounding  boxes)  with  an
  1399.                   interactive editor?
  1400.            
  1401.  
  1402.  
  1403.  
  1404.  
  1405.  
  1406.  
  1407.  
  1408.  
  1409.  
  1410.  
  1411.  
  1412.  
  1413.  
  1414.  
  1415.  
  1416.  
  1417.  
  1418.  
  1419.  
  1420.  
  1421.  
  1422.  
  1423.  
  1424.  
  1425.  
  1426.  
  1427.  
  1428.  
  1429.  
  1430.  
  1431.  
  1432.  
  1433.  
  1434.  
  1435.  
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.  
  1442.  
  1443.  
  1444.  
  1445.  
  1446.         QRT Ray Tracer               Page 22                  User Manual
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.