#! /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 'Doc/Guide/objects.tex' <<'END_OF_FILE' X\chapter{Object Definition} X 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. X XThis chapter describes objects from a strictly geometric point of Xview. Later chapters on surfaces, textures, and shading describe Xhow object appearances are defined. X XAn {\em instance} is an object that has optionally been transformed Xand 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 X\section{The World Object} X 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 X\section{Primitives} X 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. X 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. X 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 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 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 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 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 X\begin{defprim}{triangle}{\evec{p1} \evec{p2} \evec{p3}} X Creates a triangle with the given vertices. X\end{defprim} X 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 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 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 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 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 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 X 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 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 X\section{Aggregate Objects} X 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. X 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. X 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. X 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 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} X 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 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 X\section {Constructive Solid Geometry} X 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. X 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 X\subsection{CSG in Rayshade} X 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. X 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. X 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 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 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 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} X 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 X% The following aren simple CSG objects using the four consistent X% primitives: X% X% union box ... difference ... X X\subsection{Potential CSG Problems} X 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.'' X 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. X 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 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} X 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). X 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 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 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} X 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 X\section {Named Objects} X XA name may be associated with any primitive, aggregate, or CS Xobject through the use of the {\tt name} Xkeyword: X 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} X XAn object thus named may then be instantiated (with possible Xadditional transforming and texturing) via the {\tt object} keyword: X 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! fi # end of 'Doc/Guide/objects.tex' fi if test -f 'Doc/Guide/running.tex' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'Doc/Guide/running.tex'\" else echo shar: Extracting \"'Doc/Guide/running.tex'\" \(13163 characters\) sed "s/^X//" >'Doc/Guide/running.tex' <<'END_OF_FILE' X\chapter{Running Rayshade} X 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. X 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. X 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 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 X\section{The Input File} X 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. X 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. X 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. X 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 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} X 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. X 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}. X XVariables may also be defined and used in expressions. Several Xbuilt-in functions are also provided. See appendix B for further details. X 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. X XComments may be included in \rayshade input files by enclosing Xtext between the strings \verb!/*! and \verb!*/!, as in the C Xprogramming Xlanguage. X X\section{Images} X 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. X 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. X 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. X 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 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. X 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 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. X 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 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 X{\em Gamma correction} may also be applied to the three output color Xchannels. See Appendix A for more details. X X\section{Statistics Reporting} X 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 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 X\section{Antialiasing} X 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. X 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}. X 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 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 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. X 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 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. X 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 X\section{The Ray Tree} X 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 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 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 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! fi # end of 'Doc/Guide/running.tex' fi if test -f 'etc/rsconvert/yacc.y' -a "${1}" != "-c" ; then echo shar: Will not clobber existing file \"'etc/rsconvert/yacc.y'\" else 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%{ X#include X#include "libcommon/common.h" X 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%} X%union { X char *c; X int i; X double d; X Color col; X Vector v; X}; X%token tFLOAT X%token tSTRING X%token tINT X%type Fnumber sFnumber X%type sColor X%type 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 X%% XItems : /* empty */ X | Items Item X ; 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 */ X ; XList : LIST X { X NEWLINE(); X } X ; XGrid : GRID X { X NEWLINE(); X } X ; XPrimitive : Prim Textures X ; XPrim : Primtype Transforms X ; XPrimtype : Plane X | Sphere X | Box X | Triangle X | Cylinder X | Cone X | Superq X | Poly X | HeightField X ; XObject : Objectdef Textures X { X NEWLINE(); X } X ; XObjectdef : Startdef Objdefs ENDDEF X ; XStartdef : STARTDEF X /* X * define X */ X { X NEWLINE(); X } X ; XObjdefs : Objdefs Objdef X | X ; XObjdef : Primitive X | Surface X | Child X | List X | Grid X | Object X ; XTextures : Textures Texture X | X ; XTexture : TEXTURE Texturetype Transforms X { X NEWLINE(); X } X ; XTexturetype : CHECKER String X { X NEWLINE(); X } X | BLOTCH Fnumber String X { X NEWLINE(); X } X | BUMP Fnumber X { X NEWLINE(); X } X | MARBLE X { X NEWLINE(); X } X | MARBLE String X { X NEWLINE(); X } X | FBM Fnumber Fnumber Fnumber Fnumber Int Fnumber X { X NEWLINE(); X } X | FBM Fnumber Fnumber Fnumber Fnumber Int Fnumber tSTRING X { X NEWLINE(); X } X | FBMBUMP Fnumber Fnumber Fnumber Fnumber Int X { X NEWLINE(); X } X | WOOD X { X NEWLINE(); X } X | GLOSS Fnumber X { X NEWLINE(); X } X ; XChild : Childdef Textures X { X NEWLINE(); X } X ; XChilddef : OBJECT String Transforms X { X NEWLINE(); X } X ; XTransforms : Transforms Transform X | /* empty */ X ; XTransform : TRANSLATE Vector X { X NEWLINE(); X } X | ROTATE Vector sFnumber X { X WriteFloat(-$3); X NEWLINE(); X } X | SCALE Fnumber Fnumber Fnumber X { X NEWLINE(); X } X | TRANSFORM sFnumber sFnumber sFnumber X sFnumber sFnumber sFnumber X sFnumber sFnumber sFnumber X { 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 } X | TRANSFORM sFnumber sFnumber sFnumber X sFnumber sFnumber sFnumber X sFnumber sFnumber sFnumber X sFnumber sFnumber sFnumber X { 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(); X } X ; XEyep : EYEP Vector Transforms X { X NEWLINE(); X } X ; XLookp : LOOKP Vector X { X NEWLINE(); X } X ; XUp : UP Vector X { X NEWLINE(); X } X ; XFov : FOV Fnumber Fnumber X { X NEWLINE(); X } X | FOV Fnumber X { X NEWLINE(); X } X ; XSamples : SAMPLES Int X { X NEWLINE(); X } X ; XAdaptive : ADAPTIVE Int X { X NEWLINE(); X } X ; XContrast : CONTRAST Fnumber Fnumber Fnumber X { X NEWLINE(); X } X ; XCutoff : CUTOFF Fnumber X { X NEWLINE(); X } X ; XJittered : JITTERED X { X NEWLINE(); X } X ; XScreen : SCREEN Int Int X { X NEWLINE(); X } X | RESOLUTION Int Int X { X NEWLINE(); X } X ; XAperture : APERTURE Fnumber X { X NEWLINE(); X } X ; XFocaldist : FOCALDIST Fnumber X { X NEWLINE(); X } X ; XMaxdepth : MAXDEPTH Int X { X NEWLINE(); X } X ; XBackground : BACKGROUND Color X { X NEWLINE(); X } X ; XLight : Lightdef POINT Vector X { X NEWLINE(); X } X | Lightdef DIRECTIONAL Vector X { X NEWLINE(); X } X | Lightdef EXTENDED sVector sFnumber X { X WriteFloat($4); X WriteVector(&$3); X NEWLINE(); X } X ; XLightdef : LIGHT Fnumber X { X NEWLINE(); X } X | LIGHT Color X { X NEWLINE(); X } X ; XSurface : SURFACE String X sColor sColor sColor X sFnumber sFnumber sFnumber sFnumber X { 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 } X | SURFACE String sColor sColor sColor X sFnumber sFnumber sFnumber sFnumber sFnumber sFnumber X { 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 } X } X ; XHeightField : HEIGHTFIELD String String X { X NEWLINE(); X } X ; XPoly : POLY String Polypoints X { X NEWLINE(); X } X ; XPolypoints : /* empty */ X | Polypoints Polypoint X ; XPolypoint : Vector X { X NEWLINE(); X } X ; XCone : CONE String sVector sVector sFnumber sFnumber X { X /* Radii now precede points */ X WriteFloat($5); X WriteVector(&$3); X WriteFloat($6); X WriteVector(&$4); X NEWLINE(); X } X ; XCylinder : CYL String sVector sVector sFnumber X { X /* Radius now goes first */ X WriteFloat($5); X WriteVector(&$3); X WriteVector(&$4); X NEWLINE(); X } X ; XSphere : SPHERE String Fnumber Vector X { X NEWLINE(); X } X ; XBox : BOX String X sFnumber sFnumber sFnumber X sFnumber sFnumber sFnumber X { 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(); X } X ; XTriangle : TRIANGLE String Vector Vector Vector X { X NEWLINE(); X } X | TRIANGLE String Vector Vector Vector Vector Vector Vector X { X NEWLINE(); X } X ; XSuperq : SUPERQ String X Fnumber Fnumber Fnumber X Fnumber Fnumber Fnumber X Fnumber X { X NEWLINE(); X } X ; XPlane : PLANE String sVector sVector X { X /* reverse order of point/normal */ X WriteVector(&$4); X WriteVector(&$3); X NEWLINE(); X } X ; XOutfile : OUTFILE String X { X NEWLINE(); X } X ; XMist : MIST Color Color Fnumber Fnumber X { X NEWLINE(); X } X ; XFog : FOG Fnumber Color X { X NEWLINE(); X } X ; XColor : Fnumber Fnumber Fnumber X ; XsColor : sFnumber sFnumber sFnumber X { X $$.r = $1; $$.g = $2; $$.b = $3; X } X ; XVector : Fnumber Fnumber Fnumber X ; XsVector : sFnumber sFnumber sFnumber X { X $$.x = $1; $$.y = $2; $$.z = $3; X } X ; XFnumber : tFLOAT X { WriteFloat($1); } X | tINT X { WriteFloat((Float)$1); } X ; XInt : tINT X { WriteFloat((Float)$1); }; XsFnumber : tFLOAT X | tINT X { $$ = (double)$1; } X ; 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%% X X#define STARTBUFSIZ (1 << 18) X 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; X XDefBuf *defbuf = NULL; X Xyyerror(s) X{ X fprintf(stderr,"yyerror: %s\n",s); X} X XStartDefine(name) Xchar *name; X{ X DefBuf *new; X /* 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; X} X XEndDefine() X{ X char buf[BUFSIZ]; X DefBuf *old; X 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 } X /* X * dump goodies X */ X WriteVerbatim(buf); X WriteVerbatim(old->memory); X WriteVerbatim("end"); X free((voidstar)old->memory); X free((voidstar)old); X X} X XWriteString(str) Xchar *str; X{ X WriteVerbatim(str); X WriteChar(' '); X} X XWriteVerbatim(str) Xchar *str; X{ X int n; X X for (n = strlen(str); n; n--) X WriteChar(*(str++)); X} X XWriteChar(c) Xchar c; X{ 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 } X defbuf->memory[defbuf->curpos++] = c; X defbuf->memory[defbuf->curpos] = (char)NULL; X } else X putchar(c); X} X XWriteVector(v) XVector *v; X{ X WriteFloat(v->x); X WriteFloat(v->y); X WriteFloat(v->z); X} X XWriteFloat(x) XFloat x; X{ X char buf[BUFSIZ]; X sprintf(buf, "%g ", x); X WriteVerbatim(buf); X} X XWriteNewline() X{ X WriteVerbatim("\n"); X} X XSetTypeList() X{ X if (defbuf) X defbuf->type = LIST; X /* else set world type */ X} X XSetTypeGrid(x,y,z) Xint x, y, z; X{ X if (defbuf) { X defbuf->type = GRID; X defbuf->x = x; defbuf->y = y; defbuf->z = z; X } /* else set world type */ X} X XWriteColor(c) XColor *c; X{ X WriteFloat(c->r); X WriteFloat(c->g); X WriteFloat(c->b); X} END_OF_FILE if test 13171 -ne `wc -c <'etc/rsconvert/yacc.y'`; then echo shar: \"'etc/rsconvert/yacc.y'\" unpacked with wrong size! fi chmod +x 'etc/rsconvert/yacc.y' # end of 'etc/rsconvert/yacc.y' fi 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 done if test "${MISSING}" = "" ; then echo You have unpacked all 19 archives. rm -f ark[1-9]isdone ark[1-9][0-9]isdone else echo You still need to unpack the following archives: echo " " ${MISSING} fi ## End of shell archive. exit 0