home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / msdos / raytrace / portray / refman.asc < prev    next >
Encoding:
Text File  |  1994-05-25  |  38.2 KB  |  1,147 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.             PortRAY User Guide & Manual 
  7.                    Version 0.11
  8.                     April 1994
  9.  
  10.  
  11.                       Page :1 
  12.  
  13.  
  14.  
  15. PortRAY Development Team reserves the right to change Any and all details
  16. within  this manual  or the accompanying software with no  prior warning.
  17.  
  18. Acknowledgments
  19.    Darren Hewson - Early work on manual
  20.    Paul Smith    - RayTECH BBS, and for supplying the Private development
  21.                    area on RayTECH BBS.
  22.  
  23. And MANY thanks to the following people for their suggestions and testing
  24. of early versions of PortRAY.
  25.  
  26.    Raymond Ore
  27.    Martin Higgs
  28.    Joe Miller
  29.  
  30. And all the others that have taken the time to have a look at PortRAY and
  31. returned their comments and suggestions.
  32.  
  33.  
  34.                        Contents 
  35.  
  36.  
  37.                                                     Page No 
  38. 1 - Introduction                                    3 
  39.                             
  40. 2 - Ray-Tracing                                        4 
  41.                 What is Ray-Tracing                 4 
  42.                 3D Geometry                         4
  43.                 How does Ray-Tracing Work           5
  44.                 Anti-Aliasing                       5 
  45.                 Creating A Scene                    5 
  46. 3  - PortRAY                                        6
  47. 4  - Camera Files
  48. 5  - The Scene File
  49. 6  - Lights
  50. 7  - Primatives
  51. 8  - Materials
  52. 9  - Shaders
  53. 10 - Define
  54.                    
  55. Appendix A.
  56.  
  57. Descriptions of example files
  58.  
  59. Appendix B.
  60.  
  61. Descriptions of errorlevel values
  62.  
  63.                               Page: 2 
  64.  
  65. 
  66.  
  67. 1. Introduction 
  68.  
  69.    PortRAY is a European ray tracer, that is 100% ANSI C Complaint, this means 
  70. that it can be re-compiled and run on any platform that  supports ANSI C, this 
  71. also means that  there is no way to view  the output  from PortRAY while it is
  72. being rendered, this  is because of  the diverse video  and graphic  standards
  73. that would have to be included, to support all known ANSI machines. I have not 
  74. included  viewing, because  ALL platforms  have  an  abundance  of  tools  and
  75. utilities  to  view and  manipulate graphic  images so I  did not feel  that a
  76. renderer that could not view was too serious a hindrance. 
  77.  
  78.  
  79. 2. Raytracing 
  80. -------------
  81.  
  82.  What is Ray-tracing ? 
  83.  
  84.    Ray-tracing is a  technique used to  produce 'photo- realistic' images from
  85.    your computer. It works by  simulating rays of light (hence Ray-tracing) in
  86.    a 3d model  described by  the user. As  it uses simulation  of light,  real
  87.    optical  effects  such  as  reflection,   refraction  and  shadows  can  be
  88.    recreated.
  89.  
  90.    You do  not particularly need any programming or artistic skills to produce
  91.    a Ray-traced  image although  an  ability  to  think  in  3  dimensions  is
  92.    invaluable.
  93.  
  94.    You wont believe the images you can create............. 
  95.           check out the example files. 
  96.  
  97.           Skull.gif 
  98.  
  99.   3D Geometry
  100.  
  101.     At school everybody met Geometry, although this invariably would have been
  102.     the 2D variety.  If I can drag you back a few years you will remember that
  103.     a point in 2D space can be described by two co-ordinates commonly referred
  104.     to as x and y.
  105.  
  106.  
  107.           7   | 
  108.        Y  6   |             .(7,6)
  109.           5   | 
  110.           4   | 
  111.           3   | 
  112.           2   | 
  113.           1   | 
  114.               -------------------
  115.                 1 2 3 4 5 6 7 8 9 
  116.                         X
  117.  
  118.     In the example above the  point is described by the x,y co-ordinate (7,6),
  119.     that  is  7  units  up and  6 across.  Any two  dimensional shape  can  be
  120.     described using this system.
  121.  
  122.     To make the transition  to 3D geometry  all you need  do is add  the third
  123.     dimension which is known as 'z'. You can imagine the z direction as coming
  124.     straight out of the screen toward you !
  125.  
  126.  
  127.                  Y    |
  128.                       | 
  129.                       | 
  130.                       | 
  131.                       |____________________ 
  132.                      /                X
  133.                     /
  134.                    /
  135.                   / Z
  136.                  /
  137.  
  138.    Any point in 3D space can described by it's co-ordinates x,y,z. 
  139.  
  140.    In the above system the point at which the x,y,z axes cross is  called the
  141.    origin, at the origin x = y = z = 0.
  142.  
  143.  How does it Work ? 
  144.  
  145.    The  ray-tracer 'shoots' a ray  of simulated light  from the 'eye'  through
  146.    each pixel on  the screen into your 3D world  (these are referred to as eye
  147.    rays), the colour  of the pixel on  the screen is determined  by the colour
  148.    and  intensity of the light and  the colour and physical  properties of any
  149.    objects that the ray meets. 
  150.  
  151.    Rays can be reflected  or refracted depending on  the properties of objects
  152.    in the scene, each time this happens the light will acquire a little of the
  153.    colour of the surface it reflects from.
  154.  
  155.   Anti-Aliasing 
  156.  
  157.    For each pixel in  the screen a ray-tracer  normally generates one eye  ray
  158.    (a ray of light  entering the camera/eye),  other  rays  are  generated  by
  159.    reflection and refraction. However  in certain circumstances  this can lead
  160.    to  'jagged'  edges  to  the  objects  in  your  scene (especially  at  low
  161.    resolutions).  To  overcome this a  technique called anti-aliasing is used.
  162.    This effectively shoots  a number of  rays at different  parts of the pixel
  163.    and averages  the resulting colour to  produce a smoother transition at the
  164.    edge of objects.
  165.    (see section 3.1 - Cameras for details of PortRAY implementation).
  166.  
  167.  
  168.   How do I create a Scene ? 
  169.  
  170.     The 3D world you describe is constructed out of  'primitives'. A primitive
  171.     is an object such as a sphere that can be given a position size colour and
  172.     texture in a scene.  You  create  the  scene  by  defining  the  necessary
  173.     primitives in a text file which is then processed and rendered by PortRAY. 
  174.  
  175.                                                                       
  176. 3. PortRAY Raytracer 
  177. --------------------
  178.  
  179.      There are three components required to generate a PortRAY  raytrace, they
  180.      are
  181.         1) CAMERA statement
  182.         2) IMAGE statement
  183.         3) scene statements (either object, define, light, material)
  184.  
  185.      These can be grouped into one or two files, the first in the CAMERA file,
  186.      which  can  contain  CAMERA,  LIGHT  and IMAGE  statements, but NOT scene
  187.      statements. And the  second is the SCENE file, that can contain all three
  188.      different sections. If you wish, you can define one file (the SCENE file)
  189.      to contain all three sections, and so not need a seperate camera file.
  190.  
  191.      Both the  scene and camera  (if applicable)  description files needed  to
  192.      produce  a raytraced image from PortRAY should be in standard ASCII text.
  193.      PortRAY  has a scene  description  language that  is described  in  later
  194.      sections. However the  general syntax  used throughout  scene and  camera
  195.      description files is :-
  196.  
  197.      <Keyword> [<Variable Name> <Value>] ; 
  198.  
  199.      The <Variable Name> <Value> block is often repeated. Also <variable name>
  200.      can be another keyword. Command blocks are terminated with a semi-colon.
  201.  
  202.      So, for instance, the command to create a spherical object is;
  203.  
  204.      Object Sphere Centre (x y z) Radius r ; ;
  205.       This terminates the shape definition-^
  206.       This terminates the OBJECT definition--^
  207.  
  208.      Keywords  can be  in any case,  and need not be on  the same line, so the
  209.      following is exactly the same as the above
  210.  
  211.    Object
  212.       Sphere
  213.          Centre (x y z)
  214.          radius r
  215.       ;
  216.    ;
  217.  
  218.     Note how in this example the ; terminators  are lined up  with the keyword
  219.     they terminate and subsequent  keywords are indented.  Using this notation
  220.     may help to keep your object files organised and avoid syntax errors.
  221.  
  222.      All objects in PortRAY have default values so that simple images can be 
  223.      rendered, using the above example
  224.  
  225.      Object 
  226.           Sphere
  227.           ; 
  228.      ; 
  229.  
  230.      will produce a white sphere at position  0  0  0 with radius 1 
  231.  
  232.      A  file can  be included in another by the use of the include  statement.
  233.      Include statements  cannot appear inside other  statements. The format is
  234.      as follows:
  235.  
  236.           include filename.ext 
  237.  
  238.      Comments are enclosed in tilde "~" Signs.
  239.  
  240.      E.G. ~This is a comment line and will be ignored by PortRAY ~
  241.  
  242.      Anything on a line after the '//' pair, is also treated as a comment,
  243.  
  244.  
  245. 4 Camera Files 
  246. --------------
  247.  
  248.     The  camera file tells the renderer where to place the camera, what screen
  249.     resolution to use,  and if needed what lights  should be included for this
  250.     particular camera.
  251.  
  252.     Camera Statement
  253.  
  254.     The  camera  section  of  the  camera   file  details  the  geometry   and
  255.     capabilities  of the  camera  to be  used  for the  rendered  output.  The
  256.     following is a fully specified camera file:-
  257.  
  258.  
  259.       camera 
  260.           look-at (0.0 0.0 0.0) 
  261.           drop-line (0.0 -1.0 0.0) 
  262.           look-from ( 0.0 5.0 -25.0)
  263.           depth 0.028 
  264.           x-size 0.032 
  265.           y-size 0.024 
  266.           filter adaptive
  267.           ;
  268.           filter lens 
  269.                 samples 10 
  270.                 focal-length 30.0 
  271.                 radius 0.1 
  272.           ; 
  273.           filter super-sample 
  274.                 x-samples 3 
  275.                 y-samples 3 
  276.           ; 
  277.           filter disk 
  278.                 samples 10 
  279.                 radius 0.707 
  280.           ; 
  281.  
  282.       ; 
  283.  
  284.      look-from:
  285.           Is the point at which the pinhole or lens of the camera is
  286.           positioned (not to be confused with the scene origin).
  287.  
  288.      look-at: 
  289.           Is the point at which the camera is pointing.
  290.  
  291.      drop-line: 
  292.           This  is  used to form the  x co-ordinate vector  of the  screen. In
  293.           effect  this  allows  you  to  alter  the  x,y,z  directions  of the
  294.           co-ordinate system (as  outlined in section 1). It is probably not a
  295.           good idea to mess around with this unless you are experienced.
  296.  
  297.  
  298.      depth: 
  299.      x-size: 
  300.      y-size:   are the physical dimensions of the camera. 
  301.  
  302.  
  303.  
  304.  
  305.   Filters
  306.  
  307.     Filters define the properties of the camera lens (pinhole or lens) 
  308.     and the pixel sampling technique used (anti-aliasing - see section 2).
  309.  
  310.     Filters are cumulative, they can be layered on top of each other 
  311.     indefinitely (subject to RAM), if for instance you take the sample below
  312.  
  313.           filter standard 
  314.           filter lens samples 10 
  315.                focal-length 30.0 
  316.                radius 0.1 
  317.           ; 
  318.           filter super-sample 
  319.                x-samples 3 
  320.                y-samples 3 
  321.           ; 
  322.           filter disk samples 10 
  323.                radius 0.707 
  324.           ; 
  325.  
  326.  
  327.     This will generate 900! eye rays  for each pixel on screen 10x3x3x10, this
  328.     is obviously too many, they are all included with all sub-functions simply
  329.     as an example.
  330.      
  331.     Generally  you would use 1 and in some very rare circumstances 2
  332.     anti-aliasing filters, the standard filter, and for final images where 
  333.     realism is important the lens filter if needed. 
  334.  
  335.   Standard 
  336.            
  337.     This, or the adaptive filter MUST always be present, it is the filter
  338.     that turns camera and film geometry into instructions to shoot rays into
  339.     the scene. It must always be the first filter mentioned in the camera
  340.     section, any listed before this will be ignored.
  341.  
  342.   Adaptive
  343.  
  344.     This filter implements Adaptive anti-aliasing. This variety of anti-aliasing
  345.     adjusts the number of samples it makes dynamically according to the 
  346.     parameters you provide it. If the variance (in colour )between the corners 
  347.     of a pixel/sub-pixel is greater than the defined limit then the 
  348.     pixel/sub-pixel will be split up and resampled      
  349.  
  350.     Variables:
  351.       
  352.       Threshold <float>  : This sets the limit at which further samples are to
  353.                            be taken. If the difference in colour between the
  354.                            pixel or sub-pixels in question is less than this
  355.                            then no further samples will be taken.
  356.                            Default : 0.2.
  357.  
  358.       Max-depth <int>    : This defines the maximum numbe of levels the
  359.                            re-sampling will continue to.
  360.                            Default : 3.
  361.  
  362.  
  363.       cache-size <int>   : This is the size of cache to use to store previous
  364.                            trace results, this enables the system to cut out
  365.                            renders of a section that has already been traced
  366.                            NORMALLY this will not need to be changed.
  367.                            Default : 1000
  368.  
  369.       Relax <float>      : At each successive level, the THRESHOLD is
  370.                            multiplied by the RELAX figure, this forces early
  371.                            bottom-out at lower levels if the difference between
  372.                            corners is slightly larger, for instance at level 0,
  373.                            a small variance causes a section to be recursed,
  374.                            but at lower levels, the variance is not so
  375.                            important.
  376.                            Default : 1.2
  377.  
  378.      
  379.   SuperSample 
  380.  
  381.     This is an Anti-Aliasing filter, it subdivides each pixel into a 
  382.     regular grid and shoots a ray through each cell in the grid.
  383.  
  384.     Variables
  385.  
  386.       X-Samples <int> : The number of samples to take in the x direction
  387.                         Default : 2
  388.       Y-Samples <int> : The number of samples to take in the y direction
  389.                         Default : 2
  390.  
  391.   Disk 
  392.  
  393.     This is an Anti-Aliasing filter, it generates random rays in a disk 
  394.     about the centre of the pixel and accumulates the results,weighted by 
  395.     distance from the centre (i.e. in centre = 1.0 at circumference of 
  396.     disk = 0.0) The more samples the better but above about 20 no difference 
  397.     is apparent. 
  398.  
  399.     Variables
  400.  
  401.  
  402.       Radius <float> : The radius of the circle within which samples are to
  403.                        be generated
  404.                        Default : 0.707
  405.       Samples <int>  : Number of Samples to generate within the disk
  406.                        Default : 4
  407.  
  408.           
  409.   Lens 
  410.  
  411.     This Filter simulates a perfect lens (NO chromatic abberation) and allows 
  412.     depth of field and blurred images, the higher the number of samples, 
  413.     the better quality of image, but about 20 no discernible difference is 
  414.     apparent (Apart from the RUN time!) 
  415.  
  416.     Variables
  417.  
  418.       Radius <float>       : The radius of the lens to simulate (Note NOT the
  419.                              radius of curvature, but the actual aperture
  420.                              radius)
  421.                              Default : 0.1
  422.       Focal-Length <float> : The Distance from the lens from which rays will
  423.                              focus clearly onto the film
  424.                              Default : 1000.0
  425.       Samples <int>        : The number of samples to trace through the lens
  426.                              Default : 4
  427.  
  428.  
  429.   Image Statement
  430.  
  431.    The image statement sets up the image resolution and some aspects of 
  432.    image quality. 
  433.  
  434.  
  435.                image    
  436.                   xsize 320
  437.                   ysize 240
  438.                   no-shadows
  439.                   no-reflections
  440.                   nonstop
  441.                   Intersect-Buffer 1000
  442.                ; 
  443.  
  444.  
  445.      The above image statement  selects an output image resolution of 320x240
  446.      pixels and specifies no shadow and no reflection  calculations, this can
  447.      be used to  check images prior to  rendering at  higher resolutions  and
  448.      more realistic rendering. The render cannot be interrupted with anything
  449.      less than a ctrl-c. Also the  number of entries in the cache used during
  450.      adaptive anti-aliasing is specified in this example, but need not be.
  451.      (The default value is 1000)
  452.  
  453. 5 The Scene File
  454. ----------------
  455.   
  456.     The scene file is where you describe the primatives that make up your 
  457.     scene. Different objects may be defined in different scene files and
  458.     brought together by using the 'include' statement.
  459.     See Example file : dice.sce
  460.  
  461.     Scene files can also include lights and declarations of materials.
  462.  
  463.     A good practice is to use 'sce' as the extension for your scene files.
  464.  
  465. 6 Lights 
  466. --------
  467.  
  468.      What is a picture without light ? 
  469.  
  470.      This is a critical aspect of most art,  be it computer  generated or hand
  471.      drawn/painted. It is especially true of Ray-tracing, the whole appearance
  472.      of an image can be altered by just tweaking the lights.
  473.  
  474.      In PortRAY lights can be defined with the camera or the scene. The light
  475.      definition  tells PortRAY what attributes  each light has.  For instance
  476.      colour position and shape.
  477.  
  478.      Below is a typical light source definition. 
  479.  
  480.       light
  481.          colour (1.0 1.0 1.0)
  482.          position (-10.0 20.0 -5.0) 
  483.          shape sphere 
  484.             centre (-10 20.0 -5.0) 
  485.             radius 2.6 
  486.          ;
  487.          samples 20
  488.          fall-off 1
  489.          no-shadows
  490.       ;
  491.  
  492.  
  493.       This defines a spherical light source with a centre at -10, 20, -5 and 
  494.       a radius of 2.6  and a colour of white, shadows from this light source
  495.       will be sampled at 20 random positions  on the surface of the  sphere.
  496.       The light intensity will fall off at a linear relation to the distance
  497.       that the light travels,  and no shadow intersection tests will be done
  498.       against this light source.
  499.  
  500.      Values of fall off are
  501.         0 - No Fallof
  502.         1 - linear falloff
  503.         2 - squared falloff
  504.         Note, these are only examples, the user is free to use any positive
  505.         real value for falloff, so 1.2 or 3.5 are also valid falloff values.
  506.  
  507.  
  508.       Shapes (primitives) supported for light sources are:
  509.  
  510.     Sphere - standard spherical light source
  511.     
  512.     Cylinder - flourescent strip lighting ?
  513.  
  514.     Box - Use your imagination
  515.  
  516. 7 Primitives
  517. ------------
  518.  
  519.     Primitives are the shapes that you use to define your scene. Each 
  520.     primitive has colour and/or surface texture (defined via 'material')
  521.     associated with it, and can also be stretched or shrunk along all
  522.     three axes.
  523.  
  524.     Scaling, rotation, translation.
  525.        This is accomplished using the shrink/stretch commands as follows
  526.        Look at
  527.        shrink-x <float> : contracts the x-axis
  528.        shrink-y <float> : contracts the y-axis
  529.        shrink-z <float> : contracts the z-axis
  530.        stretch-x <float> : expands the x-axis
  531.        stretch-y <float> : expands the y-axis
  532.        stretch-z <float> : expands the z-axis
  533.        translate <vector> : Moves the object so that the <vector> defines the
  534.                             origin for the object definition
  535.        x-rotate <float>   : Rotates about the x axis in degrees
  536.        y-rotate <float>   :  "  "       "  "  y  "  "    "  "
  537.        z-rotate <float>   :  "  "       "  "  z  "  "    "  "
  538.  
  539.  
  540.     The primitives currently available within PortRAY are as follows:
  541.  
  542.         Spheres
  543.         Planes
  544.         Cylinders
  545.         Triangles
  546.         Boxes    
  547.         Raw data files
  548.         CSG (Constructive Solid Geometry, INTERSECT, UNION, SUBTRACT)
  549.         Disks
  550.         Polygons (Concave, convex, complex (multiple contours))
  551.  
  552.   Sphere
  553.     
  554.     I think it's fairly obvious what this primitive does, so I'll skip the 
  555.     long description !
  556.  
  557.     The variables used to decribe a sphere are listed below:-
  558.  
  559.     Required Variables:
  560.  
  561.       Centre <vec>   :  A point defining the centre of the sphere
  562.  
  563.       Radius <float> :  The radius of the sphere
  564.  
  565.     Optional Variables:
  566.  
  567.       Pole <vec>     :    A vector describing the north pole of the sphere.
  568.                           IE a line running through the centre of the sphere.
  569.                           This variable is only required if you wish to map
  570.                           a 'material' on to the sphere.
  571.  
  572.       Equator <vec>  :    A vector that defines what position the longitudinal
  573.                           axis starts at.
  574.  
  575.     Examples:
  576.  
  577.         A simple sphere definition would be:
  578.  
  579.         object
  580.            sphere
  581.               centre (0.0 0.0 0.0)
  582.               radius 4.0
  583.            ;
  584.         ;
  585.  
  586.         This would define a sphere with radius 4.0 centred on the origin.
  587.  
  588.   Plane  
  589.     
  590.     A plane primitive describes an infinite plane in 2 dimensions 
  591.     with no "thickness" in the third dimension. 
  592.  
  593.     Required Variables
  594.         Position:   This variable simply tells PortRAY where the plane 
  595.                     should be placed. 
  596.  
  597.         Normal:     A vector describing the normal of the plane, this 
  598.                     determines the orientation of the plane. A normal is 
  599.                     simply the vector at right angles to the plane.
  600.  
  601.  
  602.     Optional Variables
  603.  
  604.  
  605.         X-Axis:     Both this and the y-axis are used only for mapping
  606.                     2 dimentional shaders onto the surface of the plane.
  607.                     They should be perpendicular for a square grid, and must
  608.                     NOT be coplanar with the normal and eachother.
  609.         Y-Axis:     See above.
  610.  
  611.     Examples:
  612.  
  613.             Object
  614.                Plane
  615.                   Position (0.0 -10.0 0.0)
  616.                   Normal (0.0 1.0 0.0)
  617.                ;
  618.             ;
  619.  
  620.             This defines a 'floor' ten units below the origin of the 
  621.             scene.
  622.  
  623.   Cylinders
  624.  
  625.     The Cylinders primitive describes a 'pipe'.
  626.  
  627.     Required Variables:    
  628.  
  629.     From <vec>     : A vector defining the start of the cylinder.
  630.  
  631.     To   <vec>     : A vector defining the end of the cylinder
  632.  
  633.     Radius <float> : The radius (!) of the cylinder
  634.  
  635.     Optional Variables:
  636.  
  637.     Capped: A keyword indicating that the ends of the cylinder should be 
  638.         'filled in'.
  639.  
  640.             
  641.     Examples:
  642.  
  643.             Object
  644.                Cylinder
  645.                   From ( 10.0 0.0 0.0)
  646.                   To ( -10.0 0.0 0.0)
  647.                   Radius 1.0
  648.                   Capped
  649.                ;
  650.             ;
  651.         
  652.     This describes a simple cylinder of 20 length and 1 width with capped ends.
  653.  
  654.   Box
  655.  
  656.     This primitive defines a cuboid shape with it's edges aligned along the 
  657.     axis. 
  658.  
  659.     Required Variables:
  660.  
  661.     A (x y z) First corner of box      
  662.     B (x y z) Opposite corner of box
  663.  
  664.  
  665.     Examples:
  666.  
  667.             Object
  668.                Box
  669.                   a (0 0 0)
  670.                   b (1 1 1)
  671.                ;
  672.             ;
  673.         
  674.     This describes a simple box of with lower left corner (0 0 0) and upper
  675.     right corner (1 1 1).
  676.  
  677.  
  678.   Triangle
  679.     
  680.     This primitive is used to describe a triangle, which can be flat or 
  681.     rounded. Rounded triangles are very difficult (impossible) to hand 
  682.     calculate. Flat triangles can be useful to build irregular shapes.
  683.  
  684.     Required Variables:
  685.  
  686.       A (x y z)   Three vectors defining the 'corners' of the triangle.
  687.       B (x y z)   The triangle can be viewd from both sides.
  688.       C (x y z)   The order of the corners is not important.
  689.  
  690.     Optional Variables:
  691.  
  692.       Normal-A (x y z)  Three vectors describing the normals of the points 
  693.       Normal-B (x y z)    at each corner of the triangle. This will provide a 
  694.       Normal-C (x y z)    rounded triangle
  695.         
  696.  
  697.     Examples:
  698.  
  699.             Object
  700.                Triangle
  701.                   A ( 0.0 0.0 10.0)
  702.                   B (-5.0 0.0  0.0)
  703.                   C ( 5.0 0.0  0.0)
  704.                ;
  705.             ;
  706.  
  707.      This will produce a flat triangle.
  708.  
  709.   Raw
  710.  
  711.     This allows the inclusion of RAW triangle files into scene files
  712.     without having to convert the raw data into triangle statements,
  713.     it also allows PortRAY to compact the data by eliminating any multiple
  714.     references to single points, and at the same time allows PortRAY
  715.     to generate normals at each corner to smooth out the shape automatically
  716.  
  717.     Required Variables:
  718.  
  719.       FILE <filename> : This is the name of the file that contains the
  720.                         RAW triangle info, this MUST not have any data
  721.                         apart from the raw triangles.
  722.  
  723.     Optional Variables:
  724.  
  725.       WELD <float>       : This defines how close two points need to be
  726.                            before the system welds them into one point.
  727.                            Default : 0.00001
  728.       SMOOTH             : This tells PortRAY to generate smoothing normals
  729.                            once the triangle data is read in.
  730.       X-ROTATION <float> : No of DEGREES to rotate the triangles about the X
  731.                            axis when they are read in.
  732.       Y-ROTATION <float> : No of DEGREES to rotate the triangles about the Y
  733.                            axis when they are read in.
  734.       Z-ROTATION <float> : No of DEGREES to rotate the triangles about the Z
  735.                            axis when they are read in.
  736.       AT <vec>           : The point in the model world that will be the origin
  737.                            for the triangles.
  738.  
  739.   CSG
  740.  
  741.     This stands for CONSTRUCTIVE SOLID GEOMETRY and is a way of defining
  742.     a new shape from two others by combining them according to one of three
  743.     rules (UNION, INTERSECT and SUBTRACT).
  744.     because this uses two other objects as parameters, it can be NESTED to ANY
  745.     level, and the material used to shade a point is the material defined
  746.     by the surface that the ray actually hits, in this way you can make a die
  747.     as in EXAM_006.SCE
  748.  
  749.     Required Variables
  750.  
  751.       OPERAND1 <object>              : This is the first object
  752.       OPERAND2 <object>              : This is the second object
  753.       [UNION | INTERSECT | SUBTRACT] : This defines how to combine them
  754.  
  755.     Operators
  756.        UNION     : This one just adds the two shapes together, so you could
  757.                    for instance add a spherical cap to the end of a cylinder.
  758.        INTERSECT : This one makes the resulting shape what is inside BOTH
  759.                    operand1 AND operand2
  760.        SUBTRACT  : This takes the second shape from the first.
  761.  
  762.     Example
  763.        Look at EXAM_005.SCE and EXAM_006.SCE
  764.  
  765.   Polygon
  766.  
  767.   Disk
  768.  
  769.     Same as plane but with the inclusion of the radius <float> keyword.
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777. 8 Materials
  778. -----------
  779.  
  780.   This part of a scene file allows you to define the surface characteristics 
  781.   of the objects that you have defined in your scene. A material definition
  782.   can be created as part of the object eg:
  783.  
  784.   Object
  785.      sphere
  786.         centre (0.0 0.0 0.0)
  787.         radius 1.0
  788.      ;
  789.      material
  790.         colour (1.0 1.0 1.0)
  791.      ;
  792.   ;
  793.  
  794.   or it can be named and used later eg:
  795.  
  796.   define 
  797.     material
  798.        named flat-red
  799.        colour (1.0 0.0 0.0)
  800.     ;
  801.   ;    
  802.  
  803.   Object
  804.     primitive sphere
  805.         centre (0.0 0.0 0.0)
  806.         radius 1.0
  807.     ;
  808.     material called flat-red ;
  809.   ;
  810.  
  811.  
  812.   All the material options are as follows:
  813.  
  814.   Material
  815.     called <name>
  816.     named <name>
  817.     colour <col>
  818.  
  819.     diffuse-reflection <float>
  820.     diff-colour <col>
  821.  
  822.     specular-reflection <float>
  823.     specular-power <float>
  824.     spec-colour <col>
  825.     reflection <float>
  826.  
  827.     transparency <float>
  828.     tran-colour <col>
  829.     refractive-index <float>
  830.  
  831.     <shader-name> <shader info>
  832.   ;
  833.  
  834.  
  835.     Called: references a pre-defined material (can be included from a seperate
  836.         file)
  837.  
  838.     Named: defines a material for later use
  839.  
  840.     Colour            : this defines the basic colour of the object, and so
  841.                         sets the values of all three colours (spec, diff, tran)
  842.  
  843.     Diff-Colour       : Defines the colour used in diffuse (or Lambertian)
  844.                         reflection.
  845.  
  846.     Spec-Colour       : Defines the colour used in specular reflection.
  847.  
  848.     Tran-Colour       : Defines the colour used as the body or solid colour
  849.                         for transparent objects.
  850.  
  851.  
  852.     diffuse-relection : defines the amount of reflection, a value of 1.0
  853.                         gives a bright dull object, a value of 0.0 gives a
  854.                         dark dull object.
  855.  
  856.                         See mats1.sce/mats1.gif
  857.  
  858.     specular-reflection : defines the amount of reflectivity of the material
  859.                           A value of 1.0 will produce a shiny surface
  860.  
  861.                           See mats1.sce/mats1.gif
  862.     
  863.     specular-power      : defines the 'tightness' of the specular highlights.
  864.                           High values will give small sharp-edged highlights
  865.                           while a low value will give large soft-edged
  866.                           highlights
  867.                           See mats1.sce/mats1.gif
  868.  
  869.     reflection          : Controls the weight of the mirror reflections.
  870.  
  871.     transparency        : Defines the transparency of the surface. A value
  872.                           of 1.0 will give a totally transparent surface and a
  873.                           value of 0.0 will give a totally opaque surface.
  874.  
  875.                           see mats2.sce/mats2.gif
  876.         
  877.     refractive-index    : Defines the refractive index of the material. This is
  878.                           an index determining the amount light gets bent as it
  879.                           passes from one material (air) to the other. The
  880.                           refractive index for glass is 1.2
  881.  
  882.     <shader-name>       : This section allows you to apply 'effects' to the
  883.                           surface. Please see the shader section for more info.
  884.  
  885.  
  886.  
  887.  
  888.  
  889.  
  890.  
  891.  
  892. 9 Shaders
  893. ---------
  894.  
  895.   Shaders are broken down into two major catagories
  896.   1) Those that use the 3d position of the intersection to vary the material
  897.      eg, bumpy, fader, turb.
  898.  
  899.   2) Those that use the 2d mapping on the intersected surface to vary the
  900.      material
  901.  
  902.   Note if you are creating a shape out of several others either by DEFINE
  903.   or CSG, and wish a single variable type shader to cover the whole object
  904.   it is better to stick to the type 1 shaders above, as the 2d mappings
  905.   of each seperate sub object may not mesh very well.
  906.  
  907.  
  908.     Bricks (Type II)
  909.  
  910.       This simulates bricks, by accepting two other material definitions
  911.       and then deciding which to use to form a brick patters, see EXAM_007.SCE
  912.       note that the back wall is shaded using the brick shader.
  913.  
  914.       Variables :
  915.         MORTAR <material>   : The material that comprises the bricks
  916.         BRICK  <material>   : The material to be used for grout
  917.         SIZE   <float>      : This is the size of the brick texture, the
  918.                               greater the number, the larger the bricks
  919.  
  920.  
  921.  
  922.     Tiles (Type II)
  923.  
  924.       This simulates tiling, see EXAM_007.SCE, note that the floor is
  925.       shaded using tiles.
  926.  
  927.       Variables :
  928.         FACE <material>
  929.         GROUT <material>
  930.         TILE-WIDTH <int>
  931.         GROUT-WIDTH <int>
  932.         SIZE <float>
  933.  
  934.  
  935.     Chequers (Type II)
  936.  
  937.       Similar to above, but simulates a chequered floor, by choosing one of
  938.       two materials.
  939.  
  940.       Variables
  941.         MATERIAL-A <material> : The materials that form the
  942.         MATERIAL-B <material> : two different types of square.
  943.         SIZE <float>          : The size of the chequer board squares
  944.  
  945.     Bumpy (Type I)
  946.  
  947.       This simulates a bumpy surface, by "perturbing" the normal to the
  948.       surface at any one point.
  949.  
  950.       Variables
  951.         SIZE <float>        : This governs the size of the bump features on
  952.                               all axes at once.
  953.         TERMS <int>         : the higher the number of turms and the rougher
  954.                               the bumps will get.
  955.         XSIZE <float>       : These three terms independantly alter the
  956.         YSIZE <float>       : size of the bumps in the three axes, this
  957.         ZSIZE <float>       : allows bark type effects to be generated
  958.  
  959.         MATERIAL <material> : This allows you to overlay the bumps on another
  960.                               material, for instance to make bumpy wood.
  961.         SATURATION <float>  : This is the amount of the surface that is actually
  962.                               bumped, 0.0 and none of the surface will be bumpy,
  963.                               or 3.1416 and the whole surface will be bumpy
  964.         DEPTH <float>       : maximum depth of perturbation, Note : surface
  965.                               artifacts (or acne) can be formed when the angle
  966.                               of intersection is close to tangential to the
  967.                               surface and the depth of purturbation is too high.
  968.  
  969.     Noise (Type I)
  970.  
  971.       This is similar to bozo in Pov, but can be controlled in several ways.
  972.  
  973.       Variables
  974.         SIZE <float>        : the feature size of the noise texture.
  975.         MATERIAL <material> : This allows you to apply noise to another
  976.                               material.
  977.         VARIENCE <float>    : This defines the amplitude of the varience in
  978.                               colour that noise operates in.
  979.         COLOUR <colour>     : the base colour about which the varience operates.
  980.  
  981.  
  982.  
  983.  
  984.     Fades (Type I)
  985.  
  986.       This is perhaps the MOST powerful shader available in PortRAY, and along
  987.       with Turb3d (below) can be used to simulate all sorts of natural
  988.       materials. (woods, cloud, granite, rusty-steel)
  989.  
  990.       This shader measures how far along a defined axis, a particular point is
  991.       and then interpolates between colours or materials in a list, the shader
  992.       accepts either a list of distances and either colours or materials.
  993.       The list of entries in the material or colour list is closed by
  994.       entering 0 in the float variable, for instance
  995.  
  996.       material
  997.          fades
  998.             axis (1 1 1)
  999.             colours 0.1 (0 0 0)
  1000.                     2.0 (0 0 1)
  1001.                     0.0 (0 0 0)
  1002.          ;
  1003.       ;
  1004.       This example fades from (0 0 0) to (0 0 1) over a distance of 0.1,
  1005.       and then back again to (0 0 0) over a distance of 2.0.
  1006.       Note, never include both materials AND colours lists in a single fades
  1007.       command (its a BIT like crossing the beams in GhostBusters :) )
  1008.  
  1009.  
  1010.       Variables
  1011.         AXIS <vec>
  1012.         MATERIALS [<float> <material>]
  1013.         COLOURS   [<float> <colour>]
  1014.  
  1015.  
  1016.     Turb3d (Type I)
  1017.  
  1018.       This shader alters the 3d point that all other shaders use to base their
  1019.       outcome on by a 3d volume fractal based on the original position, this
  1020.       allows the generation of effects like wood, or cloud.
  1021.  
  1022.       Variables
  1023.          TERMS <int>         : The roughness of the fractal or the number of
  1024.                                iterations that the system goes through to
  1025.                                approximate the fractal.
  1026.          DEPTH <float>       : the maximum distance of purturbation of the 3d
  1027.                                point.
  1028.          SIZE <float>        : the maximum wavelength of the fractal
  1029.          MATERIAL <material> : the material to which the turbulence is to be
  1030.                                applied.
  1031.  
  1032. 10 Define
  1033. ---------
  1034.    This is PROBABLY the MOST useful command in PortRAY. It allows you to
  1035.    create your own objects or named materials and from there, using them
  1036.    as if they where  built in, also each defined  object and material is
  1037.    only stored once, all subsiquent uses of it are stored as pointers to
  1038.    the original and orientation information.
  1039.    The syntax is as follows
  1040.    DEFINE
  1041.       [OBJECT
  1042.          NAME ATHING
  1043.          [OBJECT
  1044.             ...
  1045.          ;]
  1046.       ;]
  1047.       [MATERIAL
  1048.          NAMED AMATERIAL
  1049.          [ ANY MATERIAL SETTINGS]
  1050.       ;]
  1051.    ;
  1052.  
  1053.  
  1054.    Once a complex object is defined in this way, it can be used just like a
  1055.    builtin object, for instance :-
  1056.  
  1057.    object
  1058.       translate (0 0 1)
  1059.       ATHING
  1060.       ;
  1061.    ;
  1062.  
  1063.    object
  1064.       translate (1 0 0)
  1065.       ATHING
  1066.       ;
  1067.    ;
  1068.  
  1069.    The requirement for the ";" after ATHING in the above example is to allow
  1070.    a position for variables to be associated with the "ATHING".
  1071.    The overhead for using a complex object like this is at least 16 bytes, and
  1072.    at MOST about 50, so it can be very efficient to generate a heirarchy of
  1073.    defined objects, to create for instance a stadium full of chairs. or
  1074.    a large fence out of smaller simple building blocks, or indeed a wall out
  1075.    of larger and larger agregates of blocks.
  1076.  
  1077.    Materials can be used is a SIMILAR way, for instance :-
  1078.  
  1079.    object
  1080.       sphere
  1081.       ;
  1082.       material
  1083.          called AMATERIAL
  1084.       ;
  1085.    ;
  1086.  
  1087.    Again the material AMATERIAL is NOT copied, it is pointed to, and so takes
  1088.    up NO extra memory for each re-use.
  1089.  
  1090.                                                                       
  1091. Appendix A. -- List and Description of EXAMPLE scene files
  1092.  
  1093. Name     Information
  1094. EXAM_001 Shows difference between Diffuse and Specular REFLECTION
  1095.          and REFRACTION
  1096.  
  1097. EXAM_002 Shows difference between the values of 10, 100 and 1000 as the
  1098.          specular-power.
  1099.  
  1100. EXAM_003
  1101. EXAM_004 Shows the combination of specular reflection and refraction to
  1102.          make a glassy material.
  1103.  
  1104. EXAM_005 Shows the three basic CSG operations
  1105. EXAM_006 Shows CSG by the construction of a die
  1106.  
  1107. EXAM_007 Shows use of TILE and Brick objects
  1108.  
  1109. BGAMMON  This and several include files generates a quite detailed view
  1110.          of a pine table with two tumblers and a backgammon board with
  1111.          brass inlays and 2 dice.
  1112.  
  1113.  
  1114.  
  1115.                                                                       
  1116. Appendix B. -- ERRORLEVEL MEANINGS
  1117.  
  1118. ErrorLevel Meaning
  1119. 0          Successful Render
  1120.  
  1121. 1          Unable to open camera file
  1122.            Unrecognised Keyword in camera section
  1123.            Unrecognised Keyword in Image section
  1124.            Unable to open scene file
  1125.            Unknown Verb in Scene file
  1126.            Attempt to use an object that does not support being the
  1127.            shape of a light.
  1128.            Unknown verb in Lightsource Definition
  1129.            Attempt to use an undefined complex object
  1130.            Unknown verb in Object Definition
  1131.            Attempt to Overlay a Material Definition with a named one
  1132.            Unrecognised/Undefined Material
  1133.            Attempt to alter characteristics of a named material
  1134.            Unknown verb in Material Definition
  1135.            Unknown verb in complex Reference
  1136.            Unknown verb in Definition Statement
  1137.            Out of memory error, Unable to allocate memort for data storage
  1138.            Intersection Buffer Exhausted
  1139.  
  1140. 2          Attempt to set number of samples for a lightsource that
  1141.            has no defined shape.
  1142.            Unable to allocate extra heap space
  1143.  
  1144.  
  1145.  
  1146.  
  1147.