home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume21
/
rayshade
/
part15
(
.txt
)
< prev
next >
Wrap
LaTeX Document
|
1991-07-21
|
47KB
|
1,158 lines
Newsgroups: comp.sources.misc
From: Rayshade Construction Co. <rayshade@weedeater.math.YALE.EDU>
Subject: v21i018: rayshade - A raytracing package for UNIX, Part15/19
Message-ID: <1991Jul21.033921.29419@sparky.IMD.Sterling.COM>
X-Md4-Signature: d11e96fffc02505dfbe7c6a125ba4161
Date: Sun, 21 Jul 1991 03:39:21 GMT
Approved: kent@sparky.imd.sterling.com
Submitted-by: Rayshade Construction Co. <rayshade@weedeater.math.YALE.EDU>
Posting-number: Volume 21, Issue 18
Archive-name: rayshade/part15
Environment: UNIX, !16BIT
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 15 (of 19)."
# Contents: Doc/Guide/objects.tex Doc/Guide/running.tex
# etc/rsconvert/yacc.y
# Wrapped by kolb@woody on Wed Jul 17 17:56:54 1991
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Doc/Guide/objects.tex' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Doc/Guide/objects.tex'\"
echo shar: Extracting \"'Doc/Guide/objects.tex'\" \(16377 characters\)
sed "s/^X//" >'Doc/Guide/objects.tex' <<'END_OF_FILE'
X\chapter{Object Definition}
XObjects in \rayshade are composed of relatively simple {\em primitive}
Xobjects. These primitives may be used by themselves, or they
Xmay be combined to form more complex objects known as {\em aggregates}.
XA special family of aggregate objects,
X{\em Constructive Solid Geometry} or CSG
Xobjects, are the result of a boolean operations applied to
Xprimitive, aggregate, or CSG objects.
XThis chapter describes objects from a strictly geometric point of
Xview. Later chapters on surfaces, textures, and shading describe
Xhow object appearances are defined.
XAn {\em instance} is an object that has optionally been transformed
Xtextured. They are the entities that are actually rendered by
X{\em rayshade}; when you specify that, for example, a textured
Xsphere is to be rendered, you are said to be instantiating
Xthe textured sphere.
XAn instance
Xis specified as a primitive, aggregate, or CSG object that
Xis followed by optional transformation and texturing information.
XTransformations and textures are described in Chapters 7 and 8 respectively.
X\section{The World Object}
XWriting a \rayshade input file is principally
Xa matter of defining a special aggregate object, the World object,
Xwhich is a list of the objects in the scene. When writing a \rayshade
Xinput file, all objects that are instantiated outside of object-definition
Xblocks are added to the World object; you need not (not should you)
Xdefine the World object explicitly in the input file.
X\section{Primitives}
XPrimitive objects are the building box with which other objects are
Xcreated. Each primitive type has associated with it specialized
Xmethods for
Xcreation,
Xintersection with a ray,
Xbounding box calculation,
Xsurface normal calculation,
Xray enter/exit classification,
Xand for the computation 2D texture coordinates termed {\em u-v}
Xcoordinates.
XThis latter method is often referred to as the {\em inverse mapping}
Xmethod.
XWhile most of these methods should be of little concern to you, the
Xinverse mapping methods
Xwill affect the way in which certain textures are applied to primitives.
XInverse mapping is a matter of computing normalized $u$ and $v$ coordinates
Xfor a given point on the surface of the primitive. For planar objects,
Xthe $u$ and $v$ coordinates of a point are computed
Xby linear interpolation based upon the $u$ and $v$ coordinates assigned
Xto vertices or other known points on the primitive. For non-planar
Xobjects, $uv$ computation can be considerably more involved.
XThis section briefly describes each primitive and
Xthe syntax that should be used to create an instance of the primitive.
XIt also describes the inverse mapping method, if any, for each type.
X\begin{defprim}{blob}{{\em thresh st r} \evec{p} [{\em st r} \evec{p} \ldots]}
X Defines a blob with consisting of a threshold equal to {\em thresh},
X and a
X group of one or more metaballs. Each metaball is defined by
X its position \evec{p}, radius {\em r}, and strength {\em st}.
X\end{defprim}
XFor now, see the source code for more explicit documentation.
XThere is no inverse mapping method for blobs.
X\begin{defprim}{box}{\evec{corner1} \evec{corner2}}
X Creates an axis-aligned box
X which has \evec{corner1} and \evec{corner2} as
X opposite corners.
X\end{defprim}
XTransformations may be applied to the box if a non-axis-aligned instance
Xis required. There is no inverse mapping method for boxes.
X\begin{defprim}{sphere}{{\em radius} \evec{center}}
X Creates a sphere with the given {\em radius} and centered at the
X given position.
X\end{defprim}
XNote that ellipsoids may be created by applying the proper scaling
Xto a sphere. Inverse mapping on the sphere is accomplished
Xby computing the longitude and latitude of the point on the sphere,
Xwith the $u$ value corresponding to longitude and $v$ to latitude.
XOn an untransformed sphere, the $z$ axis defines the poles, and the
X$x$ axis intersects the sphere at $u = 0$, $v = 0.5$. There are
Xdegeneracies at the poles: the south pole contains all points of
Xlatitude 0., the north all points of latitude 1.
X\begin{defprim}{torus}{{\em rmajor rminor} \evec{center} \evec{up}}
X Creates a torus centered at \evec{center} by rotating
X a circle with the given minor radius around the center
X point at a distance equal to the major radius.
X\end{defprim}
XIn tori inverse mapping,
Xthe $u$ value is computed using the angle of rotation about the
Xup vector, and the $v$ value is computing the angle of rotation
Xaround the tube, with $v=0$ occuring on the innermost point of the tube.
X\begin{defprim}{triangle}{\evec{p1} \evec{p2} \evec{p3}}
X Creates a triangle with the given vertices.
X\end{defprim}
X\begin{defprim}{triangle}{\evec{p1} \evec{n1} \evec{p2} \evec{n2}
X \evec{p3} \evec{n3}}
X Creates a Phong-shaded triangle with the given vertices and
X vertex normals.
X\end{defprim}
XFor both Phong- and flat-shaded triangles, the $u$ axis is the
Xvector from \evec{p1} to \evec{p2}, and the $v$ axis the vector
Xfrom \evec{p1} to \evec{p3}. There is a degeneracy at
X\evec{p3}, which contains all points with $v = 1.0$. This default
Xmapping may be modified using the {\tt triangleuv} primitive described
Xbelow.
X\begin{defprim}{triangleuv}{\evec{p1} \evec{n1} \evec{uv1}
X \evec{p2} \evec{n2} \evec{uv2}
X \evec{p3} \evec{n3} \evec{uv3}}
X Creates a Phong-shaded triangle with the given vertices,
X vertex normals. When performing texturing, the
X {\em uv} given for each vertex are used instead of the
X default values.
X\end{defprim}
XWhen computing $uv$ coordinates within the interior of the
Xtriangle, linear interpolation of the coordinates associated with
Xeach triangle vertex is used.
X\begin{defprim}{poly}{\evec{p1} \evec{p2} \evec{p3} [\evec{p4} \ldots ]}
X Creates a polygon with the given vertices. The vertices
X should be given in counter-clockwise order as one is
X looking at the ``top'' side of the polygon. The number of
X vertices in a polygon is limited only by available memory.
X\end{defprim}
XInverse mapping for arbitrary polygons is problematical.
X\Rayshade
Xpunts and equate $u$ with the $x$ coordinate of the point of intersection,
Xand $v$ with the $y$ coordinate.
X\begin{defprim}{hf}{{\em file}}
X Creates a height field defined by the altitude data stored
X in the named {\em file}. The height field is based upon
X perturbations of the unit square in the $z=0$ plane, and is
X rendered as a surface tessellated by right isosceles triangles.
X\end{defprim}
XSee Appendix B for a discussion of the format of a height field file.
XHeight field inverse mapping is straight-forward: $u$ is the
X$x$ coordinate of the point of intersection, $v$ the $y$ coordinate.
X\begin{defprim}{plane}{\evec{point} \evec{normal}}
X Creates a plane that passes through the given point and
X has the specified normal.
X\end{defprim}
XInverse mapping on the plane is identical to polygonal inverse mapping.
X\begin{defprim}{cylinder}{{\em radius} \evec{bottom} \evec{top}}
X Creates a cylinder that extends from \evec{bottom} to \evec{top}
X and has the indicated {\em radius}. Cylinders are rendered
X {\em without} endcaps.
X\end{defprim}
XThe cylinder's axis defines the $v$ axis. The $u$ axis wraps around the
Xcylinder, with $u=0$ dependent upon the orientation of the cylinder.
X\begin{defprim}{cone}{$rad_{bottom}$ \evec{bottom} $rad_{top}$ \evec{top}}
X Creats a (truncated) cone that extends from \evec{bottom} to
X \evec{top}. The cone will have a radius of $rad_{bottom}$ at
X \evec{bottom} and a radius of $rad_{top}$ at \evec{top}.
X Cones are rendered {\em without} endcaps.
X\end{defprim}
XCone inverse mapping is analogous to cylinder mapping.
X\begin{defprim}{disc}{{\em radius} \evec{pos} \evec{normal}}
X Creates a disc centered at the given position and with the
X indicated surface normal.
X\end{defprim}
XDiscs are useful for placing
Xendcaps on cylinders and cones.
XInverse mapping for the disc is based on the computation of the
Xnormalized polar coordinates of the point of intersection. The
Xnormalized radius
Xof the point of intersection is assigned to $u$, while the normalized angle
Xfrom a reference vector is assigned to $v$.
X\section{Aggregate Objects}
XAn aggregate is a collection of primitives, aggregate, and CSG
Xobjects. An aggregate, once defined, may be instantiated at will,
Xwhich means that
Xcopies that are optionally transformed and textured may be made.
XIf a scene calls for the presence of many geometrically identical
Xobjects, only one such object need be defined; the one defined object
Xmay then be instantiated many times.
XAn aggregate is one of several possible types. These aggregate types
Xare differentiated by the type of ray/aggregate intersection algorithm
X(often termed an {\em acceleration technique} or {\em efficiency scheme})
Xthat is used.
XAggregates are defined by giving a keyword that defines the
Xtype of the aggregate, followed by
Xa series of object instantiations and
Xsurface definitions, and terminated using the {\tt end} keyword.
XIf a defined object contains no instantiations, a warning message
Xis printed.
XThe most basic type of aggregate, the {\em list}, performs
Xintersection testing in the simplest possible way: Each object in the
Xlist is tested for intersection with the ray in turn, and the closest
Xintersection is returned.
X\begin{defkey}{list}{\ldots {\tt end}}
X Create a List object containing those objects instantiated between
X the {\tt list}/{\tt end} pair.
X\end{defkey}
XThe {\em grid} aggregate
Xdivides the region of space it occupies into a number of discrete
Xbox-shaped
Xvoxels. Each of these voxels contains a list of the objects that
Xintersect the voxel. This discretization makes it possible to
Xrestrict the objects
Xtested for intersection to those that are likely to hit the ray,
Xand to test
Xthe objects in nearly ``closest-first'' order.
X\begin{defkey}{grid}{{\em xvox yvox zvox} \ldots {\tt end}}
X Create a Grid objects composed of {\em xvox} by {\em yvox} by
X {\em zvox} voxels containing those objects
X instantiated between the {\tt grid}/{\tt end} pair.
X\end{defkey}
XIt is usually only worthwhile to ``engrid'' rather large,
Xcomplex collections of objects. Grids also use a great deal more
Xmemory than List objects.
X\section {Constructive Solid Geometry}
XConstructive Solid Geometry is
Xthe process of building solid objects from other solids.
XThe three CSG
Xoperators are Union, Intersection, and Difference. Each operator
Xacts upon two objects and produces a single object result.
XBy combining multiple levels of CSG operators, complex
Xobjects can be produced from simple primitives.
XThe union of two objects results in an
Xobject that encloses the space occupied by the two given objects.
XIntersection results in an object that encloses the space where the two
Xgiven objects overlap. Difference is an order dependent operator; it
Xresults in the
Xfirst given object minus the space where the second intersected
Xthe first.
X\subsection{CSG in Rayshade}
XCSG in \rayshade will generally operate properly when applied to
Xconjunction with
Xon boxes, spheres,
Xtori, and blobs.
XThese primitives are by nature consistent, as they all
Xenclose a portion of space (no hole from the "inside" to the
X"outside"), have surface normals which point outward (they
Xare not "inside-out"), and do not have any extraneous surfaces.
XCSG objects may also be constructed from aggregate objects.
XThese aggregates contain
Xwhatever is listed inside, and may therefore be inconsistent.
XFor example, an object which contains a single triangle will not
Xproduce correct results in CSG models, because the triangle does not enclose
Xspace. However, a collection of four triangles which form a pyramid
Xdoes enclose space, and if the triangle normals
Xare oriented correctly,
Xthe CSG operators should work correctly on the pyramid.
XCSG objects are specified by surrounding the objects upon
Xwhich to operate, as well as any associated surface-binding commands,
Xby the operator verb on one side and the {\tt end}
Xkeyword on the other:
X\begin{defkey}{union}{$<${\em Object}$>$ $<${\em Object}$>$
X[$<${\em Object}$>$ \ldots] {\tt end}}
X Specify a new object defined as the union of the
X given objects.
X\end{defkey}
X\begin{defkey}{difference}{$<${\em Object}$>$ $<${\em Object}$>$
X[$<${\em Object}$>$ \ldots] {\tt end}}
X Specify a new object defined as the difference of the
X given objects.
X\end{defkey}
X\begin{defkey}{intersect}{$<${\em Object}$>$ $<${\em Object}$>$
X[$<${\em Object}$>$ \ldots] {\tt end}}
X Specify a new object defined as the intersection of the
X given objects.
X\end{defkey}
XNote that the current implementation does not support more that two
Xobjects in a CSG list (but it is planned for a future version).
X% The following aren simple CSG objects using the four consistent
X% primitives:
X% union box ... difference ...
X\subsection{Potential CSG Problems}
XA consistent CSG model is one which is made
Xup of solid objects with no dangling surfaces. In {\em rayshade},
Xit is quite easy to construct inconsistent models, which will usually
Xappear incorrect in the final images.
XIn {\em rayshade}, CSG is implemented by maintaining
Xthe tree structure of the CSG operations. This tree is traversed,
Xand the operators therein applied, on a per-ray basis.
XIt is therefore difficult to verify the consistency of
Xthe model ``on the fly.''
XOne class of CSG problems occur when
Xsurfaces of objects being operated upon
Xcoincide. For example, when subtracting a box from another box to make a
Xsquare cup, the result will be wrong if the tops of the two boxes
Xcoincide. To correct this, the inner box should be made
Xslightly taller than the outer box.
XA related problem that must be
Xavoided occurs when two coincident surfaces are assigned
Xdifferent surface properties.
XIt may seem that the union operator is unnecessary, since
Xlisting two objects together in an aggregate results
Xin an image that appears to be the same.
XWhile the result of such a short-cut
Xmay appear the same on the exterior, the interior
Xof the resulting object will contain
Xextraneous surfaces.
XThe following examples show this quite clearly.
X\begin{verbatim}
X difference
X box -2 0 -3 2 3 3
X union /* change to list; note bad internal surfaces */
X sphere 2 1 0 0
X sphere 2 -1 0 0
X end
X end rotate 1 0 0 -40 rotate 0 0 1 50
X\end{verbatim}
XThe visual evidence of an inconsistent CSG object varies depending
Xupon the operator being used.
XWhen subtracting a consistent object from and
Xinconsistent one, the resulting object will appear to be
Xthe union of the two objects, but the shading will be incorrect.
XIt will appear to be inside-out in places, while correct
Xin other places. The inside-out sections indicate the areas
Xwhere the problems occur.
XSuch problems are often caused by
Xpolygons with incorrectly specified
Xnormals, or by surfaces that exactly coincide (which
Xappear as partial ``swissh-cheese'' objects).
XThe following example illustrates an attempt to subtract a sphere from
Xa pyramid defined using an incorrectly facing triangle. Note
Xthat the resulting image obviously points to which triangle is
Xreversed.
X\begin{verbatim}
X name pyramid list
X triangle 1 0 0 0 1 0 0 0 1
X triangle 1 0 0 0 0 0 0 1 0
X triangle 0 1 0 0 0 0 0 0 1
X triangle 0 0 1 1 0 0 0 0 0 /* wrong order */
X end
X difference
X object pyramid scale 3 3 3 rotate 0 0 1 45
X rotate 1 0 0 -30 translate 0 -3.5 0
X sphere 2.4 0 0 0
X end
X\end{verbatim}
XBy default, cylinders and cones do not have end caps, and thus
Xare not consistent primitives. One must usually
Xadd endcaps by listing the
Xcylinder or cone with (correctly-oriented) endcap discs in an aggregate.
X\section {Named Objects}
XA name may be associated with any primitive, aggregate, or CS
Xobject through the use of the {\tt name}
Xkeyword:
X\begin{defkey}{name}{{\em objname} $<${\em Instance\/}$>$}
X Associate {\em objname} with the given object. The
X specified object is not actually instantiated; it
X is only stored under the given name.
X\end{defkey}
XAn object thus named may then be instantiated (with possible
Xadditional transforming and texturing) via the {\tt object} keyword:
X\begin{defkey}{object}{{\em objname} [$<$Transformations$>$] [$<$Textures$>$]}
X Instantiate a copy of the object associated with {\em objname}.
X If given, the transformations and textures are composed
X with any already associated with
X the object being instantiated.
X\end{defkey}
END_OF_FILE
if test 16377 -ne `wc -c <'Doc/Guide/objects.tex'`; then
echo shar: \"'Doc/Guide/objects.tex'\" unpacked with wrong size!
# end of 'Doc/Guide/objects.tex'
if test -f 'Doc/Guide/running.tex' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Doc/Guide/running.tex'\"
echo shar: Extracting \"'Doc/Guide/running.tex'\" \(13163 characters\)
sed "s/^X//" >'Doc/Guide/running.tex' <<'END_OF_FILE'
X\chapter{Running Rayshade}
X{\em Rayshade}
Xcan take anywhere from seconds to weeks to render an image. The exact
Xtime required is a function of the speed of the
Xmachine(s) on which
Xyou're working, the complexity of the scene, and how ``good'' you want
Xthe final image to be.
XCreating a finished ray-traced image is an iterative process. Usually, many
Xtest renderings are made at low resolution and with
Xnon-essential features turned off. After each test image is created,
Xsurface definitions might be modified, the eye or look positions may be
Xslightly changed, or the intensity of a light source changed.
XThis chapter describes the basic operation of \rayshade and some of
Xthe options that control that operation.
XSetting these options properly can greatly reduce
Xrendering time, improve the quality of your images, and make you a better
Xperson.
X{\em Rayshade} usually works as a filter, reading a description from
Xthe standard input and writing
Xan image file to the standard output. As it is working, {\em rayshade} reports
Xon the progress of the rendering by writing messages to the standard
Xerror.
X\section{The Input File}
XThe scene description read by \rayshade consists of a number of
Xkeywords, each followed by a set of arguments. These keywords can
Xbe thought of as commands that direct rayshade to do various things,
Xsuch as create objects, set the eye's position, and change an object's
Xappearance.
XMany of the keywords have related command-line options for turning
Xon special features and setting values.
XThese options override the values given in the input file,
Xand are explained in detail in Appendix A.
XRayshade is ``case sensitive,'' which means that typing
X{\tt SPHERE} or {\tt Sphere} instead of {\tt sphere} won't work.
X{\em Rayshade} keywords are all lower-case. Many people choose to
Xcapitalize the first letter of names that they give to objects
Xor surfaces in order to make then ``stand out'' in an input file.
XKeywords, numbers and strings in the input file are separated by spaces,
Xtabs, or new lines (carriage returns). These ``whitespace'' characters
Xare handled identically by {\em rayshade}, which means that you can separate
Xkeywords from keywords, key words from arguments, and arguments from
Xarguments using any combination of whitespace characters that you choose.
X\begin{table}
X\centering
X\begin{tabular}{|c|c|l|}\hline\hline
XOperator & Use & Operation \\ \hline \hline
X\verb+^+ & \verb!a ^ b! & Exponentiation \\ \hline
X\verb+-+ & \verb! -a ! & Negation \\ \hline
X\verb+*+ & \verb!a * b! & Multiplication \\ \hline
X\verb+/+ & \verb!a / b! & Division \\ \hline
X\verb+%+ & \verb!a % b! & Remainder \\ \hline
X\verb-+- & \verb!a + b! & Addition \\ \hline
X\verb+-+ & \verb!a - b! & Subtraction \\ \hline \hline
X\end{tabular}
X\caption{Operators, in order of decreasing precedence.}
X\label{tab:operators}
X\end{table}
XNumbers may be entered directly as reals or as parenthesized expressions.
XReals may be written in exponential notation if you wish, and
Xintegers may be written with or without a trailing decimal point.
XWhen an integer value is called for and a real is given,
Xthe real value is truncated and the resulting integer is used.
XTable \ref{tab:operators} lists the available operators
Xavailable for use in expressions, in order of decreasing precedence.
XThe upshot of all this is that the strings
X{\tt $42$}, {\tt $42.$},
X{\tt $(20 + 22)$}, and {\tt $(7^2 - 7)$} mean the same thing
Xto {\em rayshade}.
XVariables may also be defined and used in expressions. Several
Xbuilt-in functions are also provided. See appendix B for further details.
X\Rayshade will automatically run the input it receives
Xthrough the C preprocessor if it is available. This
Xallows you to use C preprocessor directives, such as {\tt \#include},
X{\tt \#define}, and {\tt \#ifdef} when designing your input files.
XComments may be included in \rayshade input files by enclosing
Xtext between the strings \verb!/*! and \verb!*/!, as in the C
Xprogramming
Xlanguage.
X\section{Images}
XThe end result of running \rayshade is an image file. Depending upon
Xhow it was installed, \rayshade writes images in either the Utah Raster
X{\em RLE} format or a generic but easily-manipulated {\em mtv} format
Xused by Mark VandeWettering in his {\em mtv} ray tracer. The {\em mtv}
Xformat consists of a header giving the resolution of the image followed
Xby interleaved red-green-blue values for each pixel. The {\em RLE} format
Xsupports an arbitrary number of color channels,
Xan alpha channel, comments, a history field, and the ability
Xto treat images as windows into a larger image. As a result of this
Xflexibility, a number of {\em rayshade}'s features
Xare not
Xsupported if the {\em mtv} format is being used. You are thus strongly
Xencouraged to obtain a copy of the Utah Raster Toolkit.
XIf the {\em mtv}
Xformat is used, the image will (and must) consist of three eight-bit
Xcolor channels.
XIf the {\em RLE} format is used, the image file consists of three
Xeight-bit color channels plus an eight-bit alpha channel. \Rayshade
Xalso documents in the {\em RLE} header the command line and {\em gamma}
Xvalue used in creating the image.
XIf more than one frame is rendered, the resulting images are appended
Xin turn
Xto the image file. The various utilities provided by the
XUtah Raster Toolkit can be used to manipulate the resulting ``movie''
Xfiles.
XIf the Toolkit is not being used, you will probably need to write
Xutility programs to handle the decidedly non-standard mult-image ``mtv''
Xformat files.
XBy default, \rayshade writes the computed image to the standard output.
XThe image file may be written to a file instead by specifying a file name
Xin the input stream.
X\begin{defkey}{outfile}{{\em filename}}
X Write the computed image to the named file.
X\end{defkey}
XThe output file name may also be specified on the command line by
Xusing the {\tt -O} option.
XThe size of the output image is measured in pixels. The {\em x} size
Xis the number of pixels left-to-right, while the {\em y} size is
Xthe number of pixels top-to-bottom.
X\begin{defkey}{screen}{{\em xsize ysize}}
X Use a screen {\em xsize} pixels wide by {\em ysize} pixels high.
X\end{defkey}
XThe screen size may also be set on the command line through
Xthe {\tt -R} option.
XThe default
Xscreen size is 512 by 512 pixels.
XWhen rendering an image, it is often advantageous to split the image
Xinto a number of disjoint windows, each of which is rendered
Xon a different machine. One then combines the images corresponding to
Xthe windows into a final image.
X\begin{defkey}{window}{{\em minx maxx miny maxy}}
X Render the image in the given screen subwindow,
X specified in normalized units.
X\end{defkey}
XThe window must be properly
Xcontained within the screen, i.e., {\em minx} and {\em miny} must
Xbe greater than or equal to zero, while {\em maxx} and
X{\em maxy} must be less than or equal to one.
XThe {\em mtv} image file format does not support windows. The
XUtah Raster tool
X{\em rlecomp\/} is useful for reconstructing the full image from
Xsub-images.
XBy default, the window
Xis equal to ($0., 1., 0, 1$), or the entire screen.
X{\em Gamma correction} may also be applied to the three output color
Xchannels. See Appendix A for more details.
X\section{Statistics Reporting}
XAs it is working, \rayshade informs you of its progress by writing
Xmessages to a ``report file''. By default, the report file is the
Xstandard error. The report itself consists of a number of
Xprogress report lines consisting of the number of eye rays traced,
Xthe total elapsed time, and the elapsed time since the last progress report.
XThe end of the report contains detailed statistics about intersection
Xtests performed, the number of rays traced, and the like.
X\begin{defkey}{report}{[{\tt verbose}] [{\tt quiet}] [{\em freq}] [{\em file}]}
X Specify the kind of
X information included in the report and to which
X file it should be written.
X If {\tt verbose} is specified, the
X report will also include a listing of the options selected,
X the
X bounding volumes of each aggregate,
X and the total number of primitives in each aggregate.
X {\tt quiet} causes warning
X messages to be suppressed. {\em freq} specifies the frequency,
X in scanlines rendered, that progress reports are made.
X If given, {\em file} names a file to which the report
X will be written.
X\end{defkey}
XBy default, a non-verbose, non-quiet report is
Xwritten to the standard error once every 10 lines.
XThe {\tt -V} option may also be used to direct the report to a named file.
X\section{Antialiasing}
XGiven a screen of a fixed size, creating an image is accomplished by
Xsampling each pixel one or more times in order to determine what can
Xbe seen ``through'' that pixel by the camera. A pixel thus covers
Xa square area of the image plane, not just a single point.
XIf a pixel is not sampled at the proper rate, aliasing will result.
XAliasing usually appears as ``jaggies'' or ``stair steps'' in the image.
XIn order to reduce these and other artifacts, \rayshade provides
Xan adaptive jittered antialiasing scheme that attempts to detect where
Xincreased sampling rates are needed.
XIn jittered sampling, the location at which a sample is taken is
Xperturbed by a random amount. This perturbation reduces aliasing
Xbut adds noise to the image. Appendix B describes how jittered
Xtime sampling is implemented in {\em rayshade}.
XThe adaptive sampling scheme implemented in \rayshade begins
Xby sampling each pixel on the current scanline once.
XFor each pixel on the scanline, the contrast between it and its
Xfour immediate neighbors is computed. If this contrast is greater
Xthan a user-specified maximum in any color channel,
Xthe pixel and its
Xneighbors are all supersampled by firing an additional
X{$numsamples^2 -1$} rays through those pixels that have not already been
Xsupersampled. This process is repeated for the current scanline
Xuntil a pass is made without any
Xpixel being supersampled.
X\begin{defkey}{contrast}{{\em redcont greencont bluecont}}
X Set the maximum allowed contrast between four color
X samples when adaptive supersampling is used.
X The contrast test is applied to each color
X channel separately.
X\end{defkey}
XThe default maximum contrast values for the red, green, and blue
Xchannels are 0.25, 0.2, and 0.4, respectively.
X\begin{defkey}{sample}{{\em n} [{\tt nojitter}]}
X Use $n^{2} $ samples when performing jittered
X sampling. The maximum legal value is 5.
X If {\tt nojitter} is specified, sample locations
X and times will not be jittered.
X\end{defkey}
XBy default, $3^{2}$ jittered samples are taken.
XA given set of sample values must be filtered
Xin order to
Xassign a color to a pixel. Ideally, when performing filtering
Xfor a specific pixel,
Xthe filter will consider samples from neighboring regions. In
X{\em rayshade}, the filtering applied to a pixel makes use of samples
Xtaken for that pixel alone. However, one may increase the size
Xof the filter that is applied in order to approximate the results
Xa more robust filtering scheme.
X\begin{defkey}{filter}{{\em type} [{\em width}]}
X Use the indicated filter type with the given width,
X in pixels.
X Supported filter types are {\tt gauss} (gaussian)
X and {\tt box} (the default).
X\end{defkey}
XThe default filter width is 1.0 for a box filter, 1.8 for a gaussian
Xfilter. The filter and pixel centers always coincide.
XWhen sampling a pixel, samples are taken over the area of
Xthe pixel filter, which is not necessarily the same as the area
Xof the pixel itself.
XJittered sampling is used in \rayshade to sample extended light
Xsources as well. A total of $samples^2$ samples are taken of
Xeach extended light source in order to determine the extent of shadowing.
X\section{The Ray Tree}
XWhen ray tracing a scene, reflected or transmitted rays may strike
Xother reflective or transparent objects. Further reflected or
Xtransmitted rays will be spawned, and so on. Taken together, such
Xa family of rays is termed the {\em ray tree}. Care must be taken
Xto control the depth of this tree: If it is allowed to grow too deeply,
Xone may spend a great deal of time computing rays that contribute little
Xto the final picture; if it is not allowed to grow far enough, this
Xpremature tree pruning may be evident in the image.
X{\em Rayshade} provides two complimentary methods for controlling the depth
Xof the ray tree. One method sets an absolute maximum for the tree. The
Xother allows one to adaptively prune a tree as it grows so that ``unimportant''
Xrays are not spawned.
X\begin{defkey}{maxdepth}{{\em level}}
X Do not spawn rays deeper than those at the given {\em level}.
X\end{defkey}
XRays from the eye are of depth zero. The default value for
X{\em level} is 15.
XThis depth may also be set from the command line through the {\tt -D} option.
X\begin{defkey}{cutoff}{{\em threshold}}
X Do not spawn rays whose contribution to the final color of
X the eye ray is less than {\em threshold} for each color channel.
X Threshold may be given as a single floating-point value,
X or as a red-green-blue triple.
X\end{defkey}
XThe default value is 0.002. This threshold may also be set from
Xthe command line through the {\tt -T} option.
END_OF_FILE
if test 13163 -ne `wc -c <'Doc/Guide/running.tex'`; then
echo shar: \"'Doc/Guide/running.tex'\" unpacked with wrong size!
# end of 'Doc/Guide/running.tex'
if test -f 'etc/rsconvert/yacc.y' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'etc/rsconvert/yacc.y'\"
echo shar: Extracting \"'etc/rsconvert/yacc.y'\" \(13171 characters\)
sed "s/^X//" >'etc/rsconvert/yacc.y' <<'END_OF_FILE'
X/* yacc.y */
X/* */
X/* Copyright (C) 1989, 1991, Craig E. Kolb */
X/* All rights reserved. */
X/* */
X/* This software may be freely copied, modified, and redistributed, */
X/* provided that this copyright notice is preserved on all copies. */
X/* */
X/* You may not distribute this software, in whole or in part, as part of */
X/* any commercial product without the express consent of the authors. */
X/* */
X/* There is no warranty or other guarantee of fitness of this software */
X/* for any purpose. It is provided solely "as is". */
X/* $Id: yacc.y,v 4.0 91/07/17 17:11:26 kolb Exp Locker: kolb $ */
X#include <stdio.h>
X#include "libcommon/common.h"
X/*#define NEWLINE() WriteString("\n")*/
X#define NEWLINE() printf("\n")
X#define LIST 0
X#define GRID 1
Xchar yyfilename[BUFSIZ];
Xextern int yylineno;
X%union {
X char *c;
X int i;
X double d;
X Color col;
X Vector v;
X%token <d> tFLOAT
X%token <c> tSTRING
X%token <i> tINT
X%type <d> Fnumber sFnumber
X%type <col> sColor
X%type <v> sVector
X%token tADAPTIVE tAPERTURE
X%token tBACKGROUND tBLOTCH tBOX tBUMP tCONE tCYL tDIRECTIONAL
X%token tENDDEF tEXTENDED tEYEP tFBM tFBMBUMP tFOCALDIST tFOG tFOV tGLOSS tGRID
X%token tHEIGHTFIELD tJITTERED tLIGHT tLIST tLOOKP tMARBLE tMAXDEPTH tMIST
X%token tOBJECT tOUTFILE
X%token tPLANE tPOINT tPOLY tROTATE tSAMPLES
X%token tSCALE tSCREEN tSPHERE tSTARTDEF tSUPERQ tSURFACE tRESOLUTION
X%token tTHRESH tTRANSLATE tTRANSFORM tTRIANGLE tUP tENDFILE
X%token tTEXTURE tCHECKER tWOOD tCONTRAST tCUTOFF
XItems : /* empty */
X | Items Item
XItem : Eyep
X | Lookp
X | Up
X | Fov
X | Screen
X | Aperture
X | Focaldist
X | Maxdepth
X | Samples
X | Jittered
X | Adaptive
X | Contrast
X | Cutoff
X | Background
X | Light
X | Primitive
X | Child
X | Surface
X | Outfile
X | List
X | Grid
X | Object
X | Fog
X | Mist
X | ENDFILE /* For backward compatibility */
XList : LIST
X NEWLINE();
XGrid : GRID
X NEWLINE();
XPrimitive : Prim Textures
XPrim : Primtype Transforms
XPrimtype : Plane
X | Sphere
X | Box
X | Triangle
X | Cylinder
X | Cone
X | Superq
X | Poly
X | HeightField
XObject : Objectdef Textures
X NEWLINE();
XObjectdef : Startdef Objdefs ENDDEF
XStartdef : STARTDEF
X /*
X * define <name>
X */
X NEWLINE();
XObjdefs : Objdefs Objdef
XObjdef : Primitive
X | Surface
X | Child
X | List
X | Grid
X | Object
XTextures : Textures Texture
XTexture : TEXTURE Texturetype Transforms
X NEWLINE();
XTexturetype : CHECKER String
X NEWLINE();
X | BLOTCH Fnumber String
X NEWLINE();
X | BUMP Fnumber
X NEWLINE();
X | MARBLE
X NEWLINE();
X | MARBLE String
X NEWLINE();
X | FBM Fnumber Fnumber Fnumber Fnumber Int Fnumber
X NEWLINE();
X | FBM Fnumber Fnumber Fnumber Fnumber Int Fnumber tSTRING
X NEWLINE();
X | FBMBUMP Fnumber Fnumber Fnumber Fnumber Int
X NEWLINE();
X | WOOD
X NEWLINE();
X | GLOSS Fnumber
X NEWLINE();
XChild : Childdef Textures
X NEWLINE();
XChilddef : OBJECT String Transforms
X NEWLINE();
XTransforms : Transforms Transform
X | /* empty */
XTransform : TRANSLATE Vector
X NEWLINE();
X | ROTATE Vector sFnumber
X WriteFloat(-$3);
X NEWLINE();
X | SCALE Fnumber Fnumber Fnumber
X NEWLINE();
X | TRANSFORM sFnumber sFnumber sFnumber
X sFnumber sFnumber sFnumber
X sFnumber sFnumber sFnumber
X /* have to transpose... */
X WriteFloat($2); WriteFloat($5); WriteFloat($8);
X WriteFloat($3); WriteFloat($6); WriteFloat($9);
X WriteFloat($4); WriteFloat($7); WriteFloat($10);
X NEWLINE();
X | TRANSFORM sFnumber sFnumber sFnumber
X sFnumber sFnumber sFnumber
X sFnumber sFnumber sFnumber
X sFnumber sFnumber sFnumber
X /* transpose it */
X WriteFloat($2); WriteFloat($5); WriteFloat($8);
X WriteFloat($3); WriteFloat($6); WriteFloat($9);
X WriteFloat($4); WriteFloat($7); WriteFloat($10);
X WriteFloat($11); WriteFloat($12); WriteFloat($13);
X NEWLINE();
XEyep : EYEP Vector Transforms
X NEWLINE();
XLookp : LOOKP Vector
X NEWLINE();
XUp : UP Vector
X NEWLINE();
XFov : FOV Fnumber Fnumber
X NEWLINE();
X | FOV Fnumber
X NEWLINE();
XSamples : SAMPLES Int
X NEWLINE();
XAdaptive : ADAPTIVE Int
X NEWLINE();
XContrast : CONTRAST Fnumber Fnumber Fnumber
X NEWLINE();
XCutoff : CUTOFF Fnumber
X NEWLINE();
XJittered : JITTERED
X NEWLINE();
XScreen : SCREEN Int Int
X NEWLINE();
X | RESOLUTION Int Int
X NEWLINE();
XAperture : APERTURE Fnumber
X NEWLINE();
XFocaldist : FOCALDIST Fnumber
X NEWLINE();
XMaxdepth : MAXDEPTH Int
X NEWLINE();
XBackground : BACKGROUND Color
X NEWLINE();
XLight : Lightdef POINT Vector
X NEWLINE();
X | Lightdef DIRECTIONAL Vector
X NEWLINE();
X | Lightdef EXTENDED sVector sFnumber
X WriteFloat($4);
X WriteVector(&$3);
X NEWLINE();
XLightdef : LIGHT Fnumber
X NEWLINE();
X | LIGHT Color
X NEWLINE();
XSurface : SURFACE String
X sColor sColor sColor
X sFnumber sFnumber sFnumber sFnumber
X if ($3.r || $3.g || $3.b) {
X WriteString("\tambient");
X WriteColor(&$3);
X WriteNewline();
X }
X if ($4.r || $4.g || $4.b) {
X WriteString("\tdiffuse");
X WriteColor(&$4);
X WriteNewline();
X }
X if ($5.r || $5.g || $5.b) {
X WriteString("\tspecular");
X WriteColor(&$5);
X WriteNewline();
X if ($6) {
X WriteString("\tspecpow");
X WriteFloat($6);
X WriteNewline();
X }
X }
X if ($7) {
X WriteString("\treflect");
X WriteFloat($7);
X WriteNewline();
X }
X if ($8) {
X WriteString("\ttransp");
X WriteFloat($8);
X WriteString("index");
X WriteFloat($9);
X WriteNewline();
X }
X | SURFACE String sColor sColor sColor
X sFnumber sFnumber sFnumber sFnumber sFnumber sFnumber
X if ($3.r || $3.g || $3.b) {
X WriteString("\tambient");
X WriteColor(&$3);
X WriteNewline();
X }
X if ($4.r || $4.g || $4.b) {
X WriteString("\tdiffuse");
X WriteColor(&$4);
X WriteNewline();
X }
X if ($5.r || $5.g || $5.b) {
X WriteString("\tspecular");
X WriteColor(&$5);
X WriteNewline();
X if ($6) {
X WriteString("\tspecpow");
X WriteFloat($6);
X WriteNewline();
X }
X }
X if ($7) {
X WriteString("\treflect");
X WriteFloat($7);
X WriteNewline();
X }
X if ($8) {
X WriteString("\ttransp");
X WriteFloat($8);
X WriteString("index");
X WriteFloat($9);
X WriteNewline();
X }
X if ($10) {
X WriteString("\ttranslu");
X WriteFloat($10);
X WriteFloat($11);
X }
XHeightField : HEIGHTFIELD String String
X NEWLINE();
XPoly : POLY String Polypoints
X NEWLINE();
XPolypoints : /* empty */
X | Polypoints Polypoint
XPolypoint : Vector
X NEWLINE();
XCone : CONE String sVector sVector sFnumber sFnumber
X /* Radii now precede points */
X WriteFloat($5);
X WriteVector(&$3);
X WriteFloat($6);
X WriteVector(&$4);
X NEWLINE();
XCylinder : CYL String sVector sVector sFnumber
X /* Radius now goes first */
X WriteFloat($5);
X WriteVector(&$3);
X WriteVector(&$4);
X NEWLINE();
XSphere : SPHERE String Fnumber Vector
X NEWLINE();
XBox : BOX String
X sFnumber sFnumber sFnumber
X sFnumber sFnumber sFnumber
X /* give box corners */
X WriteFloat($3 - $6);
X WriteFloat($4 - $7);
X WriteFloat($5 - $8);
X WriteFloat($3 + $6);
X WriteFloat($4 + $7);
X WriteFloat($5 + $8);
X NEWLINE();
XTriangle : TRIANGLE String Vector Vector Vector
X NEWLINE();
X | TRIANGLE String Vector Vector Vector Vector Vector Vector
X NEWLINE();
XSuperq : SUPERQ String
X Fnumber Fnumber Fnumber
X Fnumber Fnumber Fnumber
X Fnumber
X NEWLINE();
XPlane : PLANE String sVector sVector
X /* reverse order of point/normal */
X WriteVector(&$4);
X WriteVector(&$3);
X NEWLINE();
XOutfile : OUTFILE String
X NEWLINE();
XMist : MIST Color Color Fnumber Fnumber
X NEWLINE();
XFog : FOG Fnumber Color
X NEWLINE();
XColor : Fnumber Fnumber Fnumber
XsColor : sFnumber sFnumber sFnumber
X $$.r = $1; $$.g = $2; $$.b = $3;
XVector : Fnumber Fnumber Fnumber
XsVector : sFnumber sFnumber sFnumber
X $$.x = $1; $$.y = $2; $$.z = $3;
XFnumber : tFLOAT
X { WriteFloat($1); }
X | tINT
X { WriteFloat((Float)$1); }
XInt : tINT
X { WriteFloat((Float)$1); };
XsFnumber : tFLOAT
X | tINT
X { $$ = (double)$1; }
XString : tSTRING
X { WriteString($1); }
XADAPTIVE : tADAPTIVE { WriteString("adaptive"); }
XAPERTURE : tAPERTURE { WriteString("aperture"); }
XBACKGROUND : tBACKGROUND { WriteString("background"); }
XBLOTCH : tBLOTCH { WriteString("blotch"); }
XBOX : tBOX { WriteString("box"); }
XBUMP : tBUMP { WriteString("bump"); }
XCONE : tCONE { WriteString("cone"); }
XCYL : tCYL { WriteString("cylinder"); }
XDIRECTIONAL : tDIRECTIONAL { WriteString("directional"); }
XENDDEF : tENDDEF { EndDefine(); }
XEXTENDED : tEXTENDED { WriteString("extended"); }
XEYEP : tEYEP { WriteString("eyep"); }
XFBM : tFBM { WriteString("fbm"); }
XFBMBUMP : tFBMBUMP { WriteString("fbmbump"); }
XFOCALDIST : tFOCALDIST { WriteString("focaldist"); }
XFOG : tFOG { WriteString("fog"); }
XFOV : tFOV { WriteString("fov"); }
XGLOSS : tGLOSS { WriteString("gloss"); }
XGRID : tGRID tINT tINT tINT { SetTypeGrid($2,$3,$4); }
XHEIGHTFIELD : tHEIGHTFIELD { WriteString("heightfield"); }
XJITTERED : tJITTERED { WriteString("jittered"); }
XLIGHT : tLIGHT { WriteString("light"); }
XLIST : tLIST { SetTypeList(); }
XLOOKP : tLOOKP { WriteString("lookp"); }
XMARBLE : tMARBLE { WriteString("marble"); }
XMAXDEPTH : tMAXDEPTH { WriteString("maxdepth"); }
XMIST : tMIST { WriteString("mist"); }
XOBJECT : tOBJECT { WriteString("object"); }
XOUTFILE : tOUTFILE { WriteString("outfile"); }
XPLANE : tPLANE { WriteString("plane"); }
XPOINT : tPOINT { WriteString("point"); }
XPOLY : tPOLY { WriteString("poly"); }
XROTATE : tROTATE { WriteString("rotate"); }
XSAMPLES : tSAMPLES { WriteString("samples"); }
XSCALE : tSCALE { WriteString("scale"); }
XSCREEN : tSCREEN { WriteString("screen"); }
XSPHERE : tSPHERE { WriteString("sphere"); }
XSTARTDEF : tSTARTDEF tSTRING { StartDefine($2); }
XSUPERQ : tSUPERQ { WriteString("superq"); }
XSURFACE : tSURFACE { WriteString("surface"); }
XRESOLUTION : tRESOLUTION { WriteString("resolution"); }
XTRANSLATE : tTRANSLATE { WriteString("translate"); }
XTRANSFORM : tTRANSFORM { WriteString("transform"); }
XTRIANGLE : tTRIANGLE { WriteString("triangle"); }
XUP : tUP { WriteString("up"); }
XENDFILE : tENDFILE { /* Don't do a thing. */ }
XTEXTURE : tTEXTURE { WriteString("texture"); }
XCHECKER : tCHECKER { WriteString("checker"); }
XWOOD : tWOOD { WriteString("wood"); }
XCONTRAST : tCONTRAST { WriteString("contrast"); }
XCUTOFF : tCUTOFF { WriteString("cutoff"); }
X#define STARTBUFSIZ (1 << 18)
Xtypedef struct db {
X int bufsiz, curpos;
X int type, x, y, z;
X char *name;
X struct db *next;
X char *memory;
X} DefBuf;
XDefBuf *defbuf = NULL;
Xyyerror(s)
X fprintf(stderr,"yyerror: %s\n",s);
XStartDefine(name)
Xchar *name;
X DefBuf *new;
X * Push new buffer onto define stack.
X */
X new = (DefBuf *)Malloc(sizeof(DefBuf));
X new->bufsiz = STARTBUFSIZ;
X new->type = LIST;
X new->curpos = 0;
X new->name = name;
X new->memory = (char *)Calloc(new->bufsiz, sizeof(char));
X new->next = defbuf;
X defbuf = new;
XEndDefine()
X char buf[BUFSIZ];
X DefBuf *old;
X old = defbuf;
X defbuf = defbuf->next;
X if (old->type == LIST) {
X sprintf(buf, "name %s list", old->name);
X } else {
X sprintf(buf, "name %s grid %d %d %d", old->name,
X old->x, old->y, old->z);
X * dump goodies
X */
X WriteVerbatim(buf);
X WriteVerbatim(old->memory);
X WriteVerbatim("end");
X free((voidstar)old->memory);
X free((voidstar)old);
XWriteString(str)
Xchar *str;
X WriteVerbatim(str);
X WriteChar(' ');
XWriteVerbatim(str)
Xchar *str;
X int n;
X for (n = strlen(str); n; n--)
X WriteChar(*(str++));
XWriteChar(c)
Xchar c;
X if (defbuf) {
X if (defbuf->curpos == defbuf->bufsiz -1) {
X defbuf->bufsiz *= 2;
X defbuf->memory = (char *)realloc(defbuf->memory,
X defbuf->bufsiz * sizeof(char));
X if (defbuf->memory == (char *)NULL) {
X fprintf(stderr,"realloc failed!\n");
X exit(-1);
X }
X defbuf->memory[defbuf->curpos++] = c;
X defbuf->memory[defbuf->curpos] = (char)NULL;
X } else
X putchar(c);
XWriteVector(v)
XVector *v;
X WriteFloat(v->x);
X WriteFloat(v->y);
X WriteFloat(v->z);
XWriteFloat(x)
XFloat x;
X char buf[BUFSIZ];
X sprintf(buf, "%g ", x);
X WriteVerbatim(buf);
XWriteNewline()
X WriteVerbatim("\n");
XSetTypeList()
X if (defbuf)
X defbuf->type = LIST;
X /* else set world type */
XSetTypeGrid(x,y,z)
Xint x, y, z;
X if (defbuf) {
X defbuf->type = GRID;
X defbuf->x = x; defbuf->y = y; defbuf->z = z;
X } /* else set world type */
XWriteColor(c)
XColor *c;
X WriteFloat(c->r);
X WriteFloat(c->g);
X WriteFloat(c->b);
END_OF_FILE
if test 13171 -ne `wc -c <'etc/rsconvert/yacc.y'`; then
echo shar: \"'etc/rsconvert/yacc.y'\" unpacked with wrong size!
chmod +x 'etc/rsconvert/yacc.y'
# end of 'etc/rsconvert/yacc.y'
echo shar: End of archive 15 \(of 19\).
cp /dev/null ark15isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
if test "${MISSING}" = "" ; then
echo You have unpacked all 19 archives.
rm -f ark[1-9]isdone ark[1-9][0-9]isdone
echo You still need to unpack the following archives:
echo " " ${MISSING}
## End of shell archive.
exit 0
exit 0 # Just in case...