#! /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/surfaces.tex' <<'END_OF_FILE'
X\chapter{Surfaces and Atmospheric Effects}
X
XSurfaces are used to control the interaction between light sources and
Xobjects. A surface specification consists of information
Xabout how the light interacts with both the exterior and
Xinterior of an object .
XFor non-closed objects, such as polygons,
Xthe ``interior'' of an object is the ``other side'' of the object's surface
Xrelative to the origin of a ray.
X
X{\Rayshade} usually ensures that a primitive's surface normal is pointing
Xtowards the origin of the incident ray when performing shading
Xcalculations. Exceptions to this rule are transparent primitives, for
Xwhich {\rayshade} uses the direction of the surface normal to determine if
Xthe incident ray is entering or exiting the object.
XAll non-transparent primitives will, in effect, be double-sided.
X
X\section{Surface Description}
X
XA surface definition consists of a number of component keywords, each
Xof which is usually followed by either a single number or a red-green-blue
Xcolor triple. Each of the values in the color triple are normalized,
Xwith zero indicating zero intensity, and one indicating full intensity.
X
XIf any surface component is left unspecified, its value defaults to zero,
Xwith the exception of the index of refraction, which is assigned the
Xdefault index of refraction (normally 1.0).
X
XSurface descriptions are used in {\rayshade} to compute the color of a ray
Xthat strikes the surface at a point \evec{P}. The normal to the surface
Xat \evec{P}, \evec{N}, is also computed.
X
X\begin{defkey}{ambient}{\evec{color}}
X Use the given {\em color} to approximate those surface-surface
X interactions (e.g., diffuse interreflection) not modeled by the
X ray tracing process.
X\end{defkey}
XA surface's ambient color is always applied to a ray. The color
Xapplied is computed by multiplying the ambient color by the intensity
Xof the ambient light source.
X
XIf \evec{P} is in shadow with respect to a given light source,
Xthat light source makes no contribution to the shading of \evec{P}.
X
X\begin{defkey}{diffuse}{\evec{color}}
X Specifies the diffuse color.
X\end{defkey}
XThe diffuse contribution from each non-shadowed light source at \evec{P}
Xis equal to the diffuse color of the surface scaled by the cosine of
Xthe angle between \evec{N}
Xand the vector from \evec{P} to the light source.
X
X\begin{defkey}{specular}{\evec{color}}
X Specifies the base color of specular reflections.
X\end{defkey}
X
X\begin{defkey}{specpow}{{\em exponent}}
X Controls the size of the specular highlight. The larger
X the {\em exponent}, the smoother the apparent finish.
X\end{defkey}
XThe intensity of specular highlights from light sources are
Xscaled by the specular color of the surface.
X
X\begin{defkey}{reflect}{{\em reflectivity}}
X Specifies the specular reflectivity of the surface. If non-zero,
X reflected rays will be spawned.
X\end{defkey}
XThe intensity of specularly reflected rays will be proportional to
Xthe specular color of the surface scaled by the reflectivity.
X
X\begin{defkey}{transp}{{\em transparency}}
X Specifies the specular transmissivity of the surface. If
X non-zero,
X transmitted (refracted) rays will be spawned.
X\end{defkey}
X
X\begin{defkey}{body}{\evec{color}}
X Specifies the body color of the object. The body color
X affects the color of rays that are transmitted through the
X object.
X\end{defkey}
X
X\begin{defkey}{extinct}{{\em coefficient}}
X Specifies the extinction coefficient of the interior
X of the object.
X\end{defkey}
XThe extinction coefficient is raised to a power equal to the distance
Xthe transmitted ray travels through the object.
XThe overall intensity of specularly transmitted rays will be proportional to
Xthis factor multiplied by the surface's body color
Xmultiplied by the transparency of the object.
X
X\begin{defkey}{index}{{\em N}}
X Specifies the index of refraction. The default value is equal
X to the index of refraction of the atmosphere surrounding the eye.
X\end{defkey}
X
X\begin{defkey}{translucency}{{\em translu} \evec{color} {\em stexp}}
X Specifies the translucency, diffusely transmitted color,
X and Phong exponent for transmitted specular highlights.
X\end{defkey}
XIf a light source illuminates a translucent surface from the side opposite
Xthat from which a ray approaches, illumination computations are performed,
Xusing the given color as the surface's diffuse color, and the given
Xexponent as the Phong highlight exponent. The resulting color is then
Xscaled by the surface's translucency.
X
X\section{Atmospheric Effects}
X
XAny number of atmospheric effects may be associated with the default
Xmedium (``air'').
X
X\begin{defkey}{fog}{\evec{color} \evec{thinness}}
XAdd exponential fog with the specified {\em thinness} and {\em color}.
X\end{defkey}
XFog is simulated by blending the color of the fog with the color of
Xeach ray. The amount of fog color blended into a ray color is an exponential
Xfunction of the distance from the ray origin to the point of intersection
Xdivided by the specified {\em thinness} for each color channel.
XIf the distance is equal to {\em thinness},
Xa ray's new color will be half of the fog color plus half its
Xoriginal color.
X
X\begin{defkey}{mist}{\evec{color} \evec{thinness} {\em zero scale}}
XAdd global low-altitude mist of the specified color. The color of
Xa ray is modulated by a fog with density that varies linearly with
Xthe difference in $z$ coordinate\footnote{This all but assumes that
Xthe default up vector (0, 0, 1) is being used.}
Xbetween the ray origin and
Xthe point of intersection. The thinness values specify the transmissivity
Xof the fog for each color channel.
XThe base altitude of the
Xmist is given by {\em zero}, and the apparent height of the mist can
Xbe modulated using {\em scale}, which scales the difference in
Xaltitude used to compute the fog.
X\end{defkey}
X
X\begin{defkey}{fogdeck}{{\em altitude} {\em offset} \evec{scale} {\em chaoscale}
X \evec{color} \evec{thinness}}
XAdd low-altitude fog, with transmissivity modulated by
Xa chaotic function.
X\end{defkey}
X
X\section {The Default Medium}
X
XThe default medium is the medium which surrounds and encompasses
Xall of the objects in the scene; it is the ``air'' through which eye
Xrays usually travel before hitting an object. The properties of
Xthe default medium may be modified through the use of the {\tt atmosphere}
Xkeyword.
X
X\begin{defkey}{atmosphere}{[{\em N\/}] [{\em atmospheric effects}]}
XIf given, {\em N} specifies the index of refraction of the default
Xmedium. The default is 1.0. Any atmospheric effects listed are applied
Xto rays that are exterior to every object in the scene (e.g., rays
Xemanating from the camera).
X\end{defkey}
X
X\begin{verbatim}
X /*
X * Red sphere on a grey plane, with fog.
X */
X eyep 0. -10. 2.
X atmosphere fog .8 .8 .8 14. 14. 14.
X plane 0 0 0 0 0 1
X sphere diffuse 0.8 0 0 1.5 0 0 1.5
X\end{verbatim}
X
X\section {Surface Specification}
X
X{\Rayshade} provides a number of ways to define surfaces and to
Xbind these surfaces to objects. The most straight-forward method
Xof surface specification is to simply list the surface properties to
Xbe used.
XAlternatively, one may associate a name with a given surface.
XThis name may subsequently be used to refer to that surface.
X
X\begin{defkey}{surface}{{\em name\/} $<${\em Surface Definition}$>$}
X Associate the given collection of surface attributes with the
X given name.
X\end{defkey}
X
XThe binding of a collection of surface properties to a given object
Xis accomplished in a bottom-up manner; the surface that ``closest''
Xin the modeling tree to the primitive being rendered is the one that
Xis used to give the primitive its appearance.
X
XAn object that has no surface bound to it is assigned a default surface
Xthat gives the appearance of white plastic.
X
XThe
Xmost direct way to bind a surface to a primitive
Xis to specify the surface when the
Xthe primitive instantiated.
XThis is accomplished
Xby inserting a list of surface attributes or a surface name after
Xthe primitive's type keyword and before the actual primitive data.
X
X\begin{verbatim}
X /*
X * A red 'mud' colored sphere reseting on a
X * white sphere. To the right is a sphere with
X * default surface attributes.
X */
X surface mud ambient .03 0. 0. diffuse .7 .3 0.
X sphere ambient .05 .05 .05 diffuse .7 .7 .7 1. 0 0 0
X sphere mud 1. 0 0 2
X sphere 1. 1.5 0 0
X\end{verbatim}
X
XHere, we define a red surface named ``mud''. We then instantiate
Xa sphere, which has a diffuse white surface bound to it. The
Xnext line instantiates a sphere with the defined ``mud'' surface bound
Xto it. The last line instantiates a sphere with no surface bound to it;
Xit is assigned the default surface by {\rayshade}.
X
XThe {\tt applysurf} keyword may be used to set the default surface
Xcharacteristics for the aggregate object currently being defined.
X
X\begin{defkey}{applysurf}{$<${\em Surface Specification}$>$}
XThe specified surface is applied to all following
Xinstantiated objects that do not have surfaces associated with them.
XThe scope of this keyword is limited to the aggregate currently
Xbeing defined.
X\end{defkey}
X
X\begin{verbatim}
X /*
X * Mirrored ball and cylinder sitting on 'default' plane.
X */
X surface mirror ambient .01 .01 .01
X diffuse .05 .05 .05
X specular .8 .8 .8 specpow 20 reflect 0.95
X plane 0 0 0 0 0 1
X applysurf mirror
X sphere 1 0 0 0
X cylinder 1 3 0 0 3 0 3
X\end{verbatim}
X
XFor convenience, the name {\tt cursurf} may be used to refer to the
Xcurrent default surface.
X
XThe utility of bottom-up binding of surfaces lies in the fact that
Xone may be as adamant or as noncommittal about
Xsurface binding as one sees fit when defining objects. For example,
Xone could define a king chess piece consisting of triangles that have no
Xsurface bound to them, save for the cross on top, which has
Xa gold-colored surface associated with it. One may then instantiate
Xthe king twice, once applying a black surface, and once applying
Xa white surface. The result: a black king and a white king, each
Xadorned with a golden cross.
X
X\begin{verbatim}
X surface white ...
X surface black ...
X surface gold ...
X ...
X define cross
X box x y z x y z
X ...
X defend
X define king
X triangle x y z x y z x y z
X ...
X object gold cross
X defend
X
X object white king translate 1. 0 0
X object black king
X\end{verbatim}
END_OF_FILE
if test 10369 -ne `wc -c <'Doc/Guide/surfaces.tex'`; then
echo shar: \"'Doc/Guide/surfaces.tex'\" unpacked with wrong size!
fi
# end of 'Doc/Guide/surfaces.tex'
fi
if test -f 'Doc/quickref.txt' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'Doc/quickref.txt'\"
else
echo shar: Extracting \"'Doc/quickref.txt'\" \(9718 characters\)
sed "s/^X//" >'Doc/quickref.txt' <<'END_OF_FILE'
X Rayshade Quick Reference
X
X-------------------------------------------------------------------------------
XKey:
X[thing] Optional item Production
XThing Number or String (thing) Default value(s)
Xthing Keyword
X-------------------------------------------------------------------------------
X
XReals and integers may be written in exponential notation, with or without a
Xdecimal point. Reals are truncated to integers when need be. Numbers may also
Xbe written as expressions surrounded by a matched pair of parentheses.
XSubexpressions may be parenthesized to control order of evaluation. Variables
Xmay be defined and used in parenthesized expressions. Predefined variables
Xinclude time (current time) and frame (current frame number, 0 - frames-1), pi,
Xdtor (pi/180), rotd (180/pi). Available operators are '+' (addition),
X'-' (subtraction and negation), '*' (multiplication), '/' (division),
X'%' (remainder), '^' (exponentiation). Functions include sin, cos, tan, asin,
Xacos, atan, sqrt, hypot.
X
XStrings are written as non-quoted strings that may include include the
Xspecial characters '/' ("slash"), '-' ("dash"), '_' ("underscore), and '.'
X("period"), in addition to upper and lowercase letters and non-leading digits.
X
X-------------------------------------------------------------------------------
XCommand-line options (override options set in input file):
X
X-A frame First frame to render
X-a Toggle alpha channel -C cutoff Adaptive tree cutoff
X-c Continued rendering -D depth Maximum ray tree depth.
X-E eye_sep Eye separation -e Exponential RLE output
X-F freq Report frequency -f Flip triangle normals
X-G gamma Gamma exponent -g Use gaussian filter
X-h Help -j Toggle jittered sampling
X-l Render left eye view -m Produce sample map
X-N frames Total frames to render -n No shadows
X-O outfile Output file name -o Toggle opaque shadows
X-P cpp-args Arguments for cpp -p Preview-quality
X-q Run quietly -R xres yres Resolution
X-r Right eye view -S samples Use Samples^2 samples
X-s Toggle shadow caching -T r g b Contrast threshold
X-u Toggle use of cpp -V filename Verbose file output
X-v Verbose output -W lx hx ly hy Render subwindow
X-X l r b t Crop window
X-------------------------------------------------------------------------------
X
XFile: /* Input file consists of...*/
X [ ... ]
X
XItem:
X
X
X
X
X
X
X
XObjItem: /* Items used in object definition blocks */
X
X
X
X
X
XViewing:
X eyep Xpos Ypos Zpos /* Eye position (0 -10 0) */
X lookp Xpos Ypos Zpos /* Look position (0 0 0) */
X up Xup Yup Zup /* "up" vector (0 0 1) */
X fov Hfov [Vfov] /* Field of view in degrees (horiontal=45) */
X aperture Width /* Aperture width (0) */
X focaldist Distance /* focal distance (|eyep - lookp|) */
X shutter Speed /* Shutter speed (0 --> no blur) */
X framelength Length /* Length of a singelf frame (1) */
X screen Xsize Ysize /* Screen size */
X window Xmin Xmax Ymin Ymax /* Window (0 xsize-1 0 ysize-1) */
X crop left right bot top /* Crop window (0 1 0 1) */
X eyesep Separation /* eye separation (0) */
X
XSurfDef: /* Give a name to a set of surface attributes. */
X surface Name [ ...]
X
XSurface: /* Surface specification */
X /* Use gven attributes */
X Surfname [ ...] /* Use named surface w/ optional mods. */
X cursurf [ ...] /* Use cur. surface w/mods - see ApplySurf */
X
XSurfSpec: /* Surface attribute specification */
X ambient R G B /* Ambient contribution */
X diffuse R G B /* Diffuse color */
X specular R G B /* Specular color */
X specpow Exponent /* Phong exponent */
X body R G B /* Body color */
X extinct Coef /* Extinction coefficient */
X transp Ktr /* Transparency */
X reflect Kr /* Reflectivity */
X index N /* Index of refraction */
X translu Ktl R G B Stpow /* Translucency, transmit diffuse, spec exp */
X noshadow /* No shadows cast on this surface */
X
XEffect: /* Atmospheric Effects */
X mist R G B Rtrans Gtrans Btrans Zero Scale
X fog R G B Rtrans Gtrans Btrans
X
XAtmosphere: /* Global atmosphere */
X atmosphere [Index] [...] /* Global index, effects */
X
XApplySurf:
X applysurf /* apply surf to all following objs w/o surface */
X
XInstance: /* Instance of an object */
X