home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume21 / rayshade / part08 < prev    next >
Encoding:
Internet Message Format  |  1990-03-21  |  37.4 KB

  1. Subject:  v21i015:  A ray tracing program, Part08/08
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Craig Kolb <craig@weedeater.math.yale.edu>
  7. Posting-number: Volume 21, Issue 15
  8. Archive-name: rayshade/part08
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 8 (of 8)."
  17. # Contents:  doc/rayshade.1
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f 'doc/rayshade.1' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'doc/rayshade.1'\"
  21. else
  22. echo shar: Extracting \"'doc/rayshade.1'\" \(35763 characters\)
  23. sed "s/^X//" >'doc/rayshade.1' <<'END_OF_FILE'
  24. X.\" Manual page for rayshade, 'troff -man' format.
  25. X.\"
  26. X.\" $Id: rayshade.1,v 3.0 89/10/27 16:55:22 craig Exp $
  27. X.\"
  28. X.\" $Log:    rayshade.1,v $
  29. X.\" Revision 3.0  89/10/27  16:55:22  craig
  30. X.\" Baseline for first official release.
  31. X.\" 
  32. X.\" Updated by C. Kolb  7/1/88 12/21/88 6/8/89 9/11/89 10/6/89 10/16/89
  33. X.\" Initial version May 12, 1988 Craig Kolb
  34. X.TH RAYSHADE  1G "September 11, 1989"
  35. X.UC 4
  36. X.SH NAME
  37. Xrayshade \- a raytracing program
  38. X.SH SYNOPSIS
  39. X.B rayshade
  40. X[
  41. X.I options
  42. X] [
  43. X.I filename
  44. X]
  45. X.SH DESCRIPTION
  46. X.I Rayshade
  47. Xreads a file describing a scene to be rendered and produces a
  48. XUtah Raster RLE format file of the raytraced image.
  49. X.br
  50. X.SH OPTIONS
  51. X.TP
  52. X.B \-C \fIred_contrast green_contrast blue_contrast\fR
  53. XSet contrast factors used in controlling pixel subdivision.
  54. X.TP
  55. X.B \-c
  56. XTrace shadow rays through transparent objects.
  57. X.TP
  58. X.B \-E \fIeye_separation\fR
  59. XSet eye separation for stereo imaging.
  60. X.TP
  61. X.B \-h
  62. XPrint a short usage message.
  63. X.TP
  64. X.B \-j
  65. XPerform jittered sampling.
  66. X.TP
  67. X.B \-L \fIstart_line\fR
  68. XBegin trace on line \fIstart_line\fR, appending to image file (requires
  69. X\fB-O\fR option).
  70. X.TP
  71. X.B \-l
  72. XRender image for left eye (requires \fB-E\fR option).
  73. X.TP
  74. X.B \-n
  75. XDo not trace shadow rays.
  76. X.TP
  77. X.B \-O \fIoutput_file\fR
  78. XOverride image file name in input file, if any.
  79. X.TP
  80. X\fB\-P\fI pixel_subdivisions\fR
  81. XSpecifies the maximum number of times a pixel may be subdivided.
  82. X.TP
  83. X.B \-p
  84. XDiscard polygons with degenerate edges.
  85. X.TP
  86. X.B \-q
  87. XDo not print warning messages.
  88. X.TP
  89. X.B \-R \fIxres yres\fR
  90. XSet image resolution.
  91. X.TP
  92. X.B \-r
  93. XRender image for right eye (requires \fB-E\fR option).
  94. X.TP
  95. X.B \-S \fIsamples\fR
  96. XSpecifies number of jittered samples.
  97. X.TP
  98. X.B \-s
  99. XDo not cache shadowing information.
  100. X.TP
  101. X.B \-T \fIthresh\fR
  102. XSpecifies adaptive ray-depth cutoff threshold.
  103. X.TP
  104. X.B \-V \fIfilename\fR
  105. XWrite verbose output to \fIfilename\fR.
  106. X.TP
  107. X.B \-v
  108. XWrite verbose output to standard output.
  109. X.TP
  110. X.B \-W \fIworkers\fR
  111. XSpecify number of worker processes (Linda implementation only).
  112. X.br
  113. X.SH OVERVIEW
  114. X.PP
  115. X.I Rayshade
  116. Xis an raytracer capable of raytracing images of objects composed
  117. Xof a large number of primitive objects.
  118. X.I Rayhade
  119. Xreads a series of lines supplied on the standard input or contained
  120. Xin the file named on the command line.
  121. XAfter reading the input file,
  122. X.I rayshade
  123. Xraytraces the image from
  124. Xthe bottom upwards.  As each scanline is traced, pixels are written to
  125. Xa Utah Raster RLE format image file.  By default, this image file is written
  126. Xto the standard output, and
  127. Xinformation messages and statistics
  128. Xare written to the standard error.
  129. X.br
  130. X.SH "INPUT FILE FORMAT"
  131. X.PP
  132. XThe input file consists of commands (denoted by keywords) followed by
  133. Xnumerical
  134. Xor character
  135. Xarguments.
  136. XSpaces, tabs, or newlines may be used to separate items in the file.
  137. XCoordinates and
  138. Xvectors are specified in arbitrary floating-point units, and may be
  139. Xwritten with or without a decimal point.
  140. XColors are specified as
  141. Xred-green-blue floating-point triplets which indicate intensity
  142. Xand range from 0
  143. X(zero intensity) to 1. (full intensity).
  144. X.PP
  145. XA
  146. X.B #include
  147. Xdirective is supported which, as in the C language,
  148. Xcauses the contents of the quoted filename which follows to be read and
  149. Xeffectively inserted at that point in the input file.  Be warned that
  150. X.I rayshade
  151. Xdoes no checking for mutual or recursive inclusion of files.
  152. X.PP
  153. XThe following sections describe the keywords which may be included
  154. Xin the input file.  Items in boldface type are literals, while 
  155. Xsquare brackets surround optional items.
  156. X.br
  157. X
  158. X.SH "VIEWING PARAMETERS"
  159. X.TP
  160. X\fBeyep\fI x y z\fR
  161. XSpecifies the eye's position in space.  The default is (0, 20, 0).
  162. X.TP
  163. X\fBlookp\fI x y z\fR
  164. XSpecifies the point at which the eye is looking.  The default is (0, 0, 0).
  165. X.TP
  166. X\fBup\fI x y z\fR
  167. XSpecifies the direction which should be considered
  168. X"up" from the eye's position.  Note that
  169. Xthis vector need not be perpendicular to the vector between the look point
  170. Xand the eye's position.  The default is (0, 0, 1.).
  171. X.TP
  172. X\fBfov\fI horizontal_field_of_view \fR[\fIvertical_field_of_view\fR]
  173. XThe horizontal field of view specifies the angle, in degrees,
  174. Xbetween the left-most and right-most
  175. Xcolumns of pixels 
  176. XIf present, the vertical
  177. Xfield of view specifies the angle between
  178. Xthe center of the top-most and bottom-most row of pixels.
  179. XIf not present, the vertical field of view
  180. Xis calculated using the screen resolution and the assumption that pixels are
  181. Xsquare.
  182. XThe default horizontal field-of-view is 45 degrees, while the default vertical
  183. Xfield-of-view
  184. Xis calculated as described above.
  185. X.br
  186. X.SH "IMAGE GENERATION"
  187. XWhen specified in the input file, many of the image-generation commands
  188. Xmay be overridden through command-line options.  For example, the line
  189. X"screen 1024 768" in an input file may be overridden by specifying
  190. X"-R 128 128" on the command line.
  191. X.TP
  192. X\fBscreen \fIx_resolution y_resolution\fR
  193. XSpecifies the horizontal and vertical resolution of the image to be traced.
  194. XThis command may be overridden through use of
  195. Xthe \fB-R\fR option.
  196. XThe default resolution
  197. Xis 512 by 512 pixels.
  198. X.TP
  199. X\fBbackground \fIred green blue\fR
  200. XSpecifies the color that should be assigned to rays
  201. Xwhich do not strike any object in the scene.
  202. XThe default is black (0, 0, 0).
  203. X.TP
  204. X\fBoutfile \fIfilename\fR
  205. XSpecifies the name of the file to which the resulting image should be
  206. Xwritten.
  207. XBy default, the image is written to the standard output.
  208. XThis command may be overridden through the use of the \fB-O\fR option.
  209. X.TP
  210. X\fBmaxdepth \fImaximum_depth\fR
  211. XControls the maximum depth of the ray tree.  The default is 3, with eye
  212. Xrays considered to be of depth zero.
  213. X.TP
  214. X\fBcutoff \fIcutoff_threshold\fR
  215. XSpecifies the adaptive ray-depth cutoff threshold.  When any ray's maximum
  216. Xcontribution
  217. Xto the final color of a pixel falls below this value, the ray and its children
  218. X(specularly transmitted and reflected rays) are not spawned.
  219. XThis threshold may be overridden through
  220. Xthe use of the
  221. X\fB-T\fR option.  The default value is 0.001.
  222. X.TP
  223. X\fBjittered\fR
  224. XUse "jittered" sampling.  This command may be overridden through the use
  225. Xof the \fB-P\fR option.  The default is to use adaptive supersampling.
  226. X.TP
  227. X\fBadaptive \fImax_divisions\fR
  228. XSpecifies that adaptive supersampling should be used, and that each pixel
  229. Xmay be subdivided at most \fImax_divisions\fR times.
  230. XThis command may be overridden through the use of the \fB-j\fR
  231. Xor \fB-P\fR options.
  232. XThe default value is one.
  233. X.TP
  234. X\fBsamples \fInum_samples\fR
  235. XSpecifies the number of jittered samples.  See SAMPLING for details.
  236. XWhen specified, this value may be overridden through the use of the
  237. X\fB-S\fR option.  The default value is three.
  238. X.TP
  239. X\fBcontrast \fIred green blue\fR
  240. XSpecifies the maximum allowed contrast between samples in a (sub)pixel
  241. Xbefore subdivision takes place.  See SAMPLING for details.
  242. XWhen specified in the input file, these
  243. Xvalues may be overridden through the use of the \fB-C\fR option.  The
  244. Xdefaults for the red, green and blue channels are 0.25, 0.2, and 0.4,
  245. Xrespectively.
  246. X.SH "LIGHT SOURCES"
  247. X.PP
  248. XThree types of light sources are supported:  point, extended (area), and
  249. Xdirectional.
  250. XPoint sources are specified by a location in world-space
  251. Xand produce shadows with sharp edges.  Extended sources are specified
  252. Xby a location and a radius.  They produce shadows with "fuzzy" edges
  253. X(penumbrae), but increase ray-tracing time considerably.  Directional
  254. Xsources are specified by a direction.
  255. XA maximum of 10 light sources may be defined.
  256. X.PP
  257. XIn the definitions below,
  258. X.I brightness
  259. Xspecifies the intensity of the light source.  If a
  260. Xsingle floating-point number is given, the light source emits a "white" light
  261. Xof the indicated normalized intensity.  If three floating-point numbers
  262. Xare given, they are interpreted as the normalized red, green and blue
  263. Xcomponents of the light source's color.
  264. X.PP
  265. XLights are defined as follows:
  266. X.TP
  267. X\fBlight \fIbrightness \fBpoint\fI x y z\fR
  268. XCreates a point source located at (
  269. X.I x, y, z
  270. X).
  271. X.TP
  272. X\fBlight \fIbrightness \fBextended\fI x y z radius\fR
  273. XCreates an extended source centered at
  274. X(
  275. X.I x, y, z
  276. X)
  277. Xwith the indicated \fIradius\fR.  The images produced using extended sources
  278. Xare usually superior to those produced using point sources, but ray-tracing
  279. Xtime is increased substantially.  Rather than tracing one shadow
  280. Xray to a light source, multiple rays
  281. Xare traced to various points on the extended source.  The extended source
  282. Xis approximated by sampling a square grid light sources.
  283. XSee SAMPLING for more details on the
  284. Xsampling of extended light sources.
  285. X.TP
  286. X\fBlight \fIbrightness \fBdirectional\fI x y z\fR
  287. XCreates a directional
  288. Xlight source whose direction vector from each point
  289. Xin world space is defined as
  290. X(
  291. X.I x, y, z
  292. X).  This vector need not be normalized.
  293. X.br
  294. X.SH SURFACES
  295. X.PP
  296. XEvery primitive object has a surface associated with it.  The surface specifies 
  297. Xthe color, reflectivity, and transparency of an object, and may be
  298. Xdefined anywhere in the input file as long as it is defined before it
  299. Xis used.
  300. XSurfaces are
  301. Xdefined once, and may be associated with any number of primitive objects.
  302. XA surface definition is given by:
  303. X.TP
  304. X\fBsurface \fIsurf_name ar ag ab dr dg db sr sg sb coef refl transp index \fR[\fItranslu stcoef\fR]
  305. X.PP
  306. X.I Surf_name
  307. Xis the name associated with
  308. Xthe surface.  This name must be unique for each surface.
  309. X.PP
  310. X.I Ar, ag
  311. Xand
  312. X.I ab
  313. Xare used to specify the red, green, and blue components of the surface's
  314. Xambient color.  This color is always applied to a ray striking the surface.
  315. X.PP
  316. X.I Dr, dg
  317. Xand
  318. X.I db
  319. Xspecify the diffuse color of the surface.  This color, the
  320. X.I brightness
  321. Xcomponent of each light source whose light strikes the surface, and
  322. Xdot product of the incoming ray and the surface normal at the point of
  323. Xintersection
  324. Xdetermine the color which is added to the color of the ray striking
  325. Xthe surface.
  326. X.PP
  327. X.I Sr, sg
  328. Xand
  329. X.I sb
  330. Xare used to specify the specular color of the surface.  The application of
  331. Xthis color is controlled by the
  332. X.I coef
  333. Xparameter, a floating-point number which indicates the power to which the
  334. Xdot product of the surface's normal vector at the point of intersection
  335. Xand the vector to each light source should be raised.  This number is
  336. Xthen used to scale the specular color of the surface, which is then added
  337. Xto the color of the ray striking the surface.
  338. XThis model (Phong lighting) simulates specular
  339. Xreflections of light sources on the surface of the object.
  340. XThe larger
  341. X.I coef
  342. Xis, the smaller highlights will be.
  343. X.PP
  344. X.I Refl
  345. Xis a floating-point number between 0 and 1 which indicates the reflectivity
  346. Xof the object.  If non-zero, a ray striking the surface will spawn
  347. Xa reflection ray. The color assigned to that ray will be scaled
  348. Xby
  349. X.I refl
  350. Xand added to the color of the surface.
  351. X.PP
  352. X.I Transp
  353. Xis
  354. Xa floating-point number between 0 and 1
  355. Xwhich indicates the transparency of the object.  If non-zero,
  356. Xa ray striking the surface will spawn a ray which is transmitted through
  357. Xthe object,
  358. Xand the resulting color of this ray is scaled by
  359. X.I transp
  360. Xand added to
  361. Xthe color of the surface.  The direction of the refraction
  362. Xray is controlled by the
  363. X.I index
  364. Xparameter, which indicates the index of refraction of
  365. Xthe surface.
  366. X.PP
  367. XThe optional parameters \fItranslu\fR and \fIstcoef\fR may be used
  368. Xto give a surface a translucent appearance.  \fITranslu\fR is the
  369. Xtranslucency of the surface.   If non-zero and a light source
  370. Xilluminates the side of the surface opposite that being rendered,
  371. Xdiffuse lighting calculations are performed with respect to
  372. Xthe side of the surface facing the light,
  373. Xand
  374. Xthe result is 
  375. Xscaled by \fItranslu\fR and added to the color of the incident ray.
  376. XThus, \fItranslu\fR accounts for diffuse transmission of light
  377. Xthrough the primitive.
  378. X\fIStcoef\fR is similar to \fIcoef\fR, but it applies to the specular
  379. Xtransmission of highlights.  Note that in both cases the index
  380. Xof refraction of the surface is ignored.  By default, surfaces
  381. Xhave zero translucency.
  382. X.br
  383. X.SH PRIMITIVES
  384. X.PP
  385. XThe raytracer is capable of rendering a number of primitive objects.
  386. XPrimitives may be specified inside of an object-definition block, in
  387. Xwhich case it is added to the list of primitives belonging to that
  388. Xobject. In addition, primitives may be defined
  389. Xoutside of object-definition blocks.  Primitives such as these are
  390. Xadded to the list of primitives belonging to the World object.  See
  391. Xbelow for more details.
  392. X.PP
  393. XRayshade usually ensures that a primitive's normal is pointing
  394. Xtowards the origin of the incident ray when performing shading calculations.
  395. XExceptions
  396. Xto this rule are transparent primitives, for which rayshade uses the
  397. Xdot product of the normal and the incident ray to determine if the ray
  398. Xis entering or exiting the surface, and superquadrics, whose normals
  399. Xare never modified due to the nature of the ray/superquadric interesection
  400. Xcode.  Thus, all non-transparent primitives except superquadrics will in
  401. Xeffect be double-sided.
  402. X.PP
  403. XPrimitives are specified by lines of the form:
  404. X.TP
  405. X.I
  406. Xprimitive_type surface <primitive definition>
  407. X.in +16
  408. X[\fItransformations\fR] [\fItexture mapping information\fR]
  409. X.in -16
  410. X.br
  411. X\fISurface\fR is the name of the surface to be associated with the
  412. Xprimitive.
  413. XTexture mapping and transformations are
  414. Xdiscussed below.  A list of available primitives
  415. Xfollows.
  416. X.br
  417. X.TP
  418. X\fBsphere \fIsurface radius xcenter ycenter zcenter\fB
  419. XCreates a sphere with the indicated
  420. X.I radius
  421. Xcentered at (
  422. X.I xcenter, ycenter, zcenter
  423. X).
  424. X.TP
  425. X\fBtriangle \fIsurface x1 y1 z1 x2 y2 z2 x3 y3 z3\fR
  426. XCreates a triangle with vertices (
  427. X.I x1, y1, z1
  428. X), (
  429. X.I x2, y2, z2
  430. X) and (
  431. X.I x3, y3, z3
  432. X).  Vertices should be given in a counter-clockwise order as one is
  433. Xlooking at the 'top' face of the triangle.
  434. X.TP
  435. X\fBtriangle \fIsurface p1x p1y p1z n1x n1y n1z  p2x p2y p2z n2x n2y n2z\fR
  436. X.in +16
  437. X\fIp3x p3y p3z n3x n3y n3z\fR
  438. X.in -16
  439. XDefines a Phong-shaded triangle.  Here, the first three floating-point numbers
  440. Xspecify the first vertex, the second three specify the
  441. Xnormal at that vertex, and so on.  Again, vertices should be
  442. Xspecified in counter-clockwise order.
  443. XCurrently, all three vertex/normal pairs
  444. Xare stored for every triangle (as opposed to storing pointers to these
  445. Xvectors, which would reduce storage space in cases where more than one
  446. Xtriangle shared a vertex).
  447. X.TP
  448. X\fBpoly \fIsurface x1 y1 z1 x2 y2 z2 x3 y3 z3 \fR[\fIx4 y4 z4 ...\fR]
  449. XCreates a polygon with the specified vertices.  The vertices should be given in
  450. Xa counter-clockwise order as one faces the "top" of the polygon.
  451. XThe polygon may be non-convex,
  452. Xbut non-planar polygons will not be rendered correctly.  The number of vertices
  453. Xdefining a polygon is limited only by available memory.
  454. X.TP
  455. X\fBplane \fIsurface xnormal ynormal znormal x y z\fR
  456. XCreates a plane which passes through the point (
  457. X.I x, y, z
  458. X) and has normal (
  459. X.I xnormal, ynormal, znormal
  460. X).
  461. X.TP
  462. X\fBcylinder \fIsurface xbase ybase zbase xtop ytop ztop radius\fR
  463. XCreates a cylinder which extends from (\fIxbase\fR, \fIybase\fR, \fIzbase\fR)
  464. Xto (\fIxtop\fR, \fIytop\fR, \fIztop\fR) and has the indicated \fIradius\fR.
  465. X.TP
  466. X\fBcone \fIsurface xbase yase zbase xtop ytop ztop base_radius top_radius\fR
  467. XCreates a (truncated)
  468. Xcone which extends from (xbase, ybase, zbase) to (xtop, ytop, ztop).
  469. XThe bottom of the cone will have radius
  470. X.I base_radius,
  471. Xwhile the top will have radius
  472. X.I top_radius.
  473. X.TP
  474. X\fBheightfield \fIfilename\fR
  475. XReads height field data from \fIfilename\fR and creates a height square
  476. Xheight field of unit size centered at (0.5, 0.5).  The binary data in
  477. X\fIfilename\fR
  478. Xis stored as an initial integer giving the square root of number of data
  479. Xpoints in the file, followed by the data stored as floating-point
  480. Xnumbers.  The height field is rendered as a surface tessellated by triangles.
  481. XNon-square height fields may be rendered by setting vertex heights to
  482. Xless than or equal to -1000.  Triangles which have all vertices less than
  483. Xor equal in altitude to this value are not rendered.
  484. X.TP
  485. X\fBbox \fIsurface xcenter ycenter zcenter xsize ysize zsize\fR
  486. XCreates a box centered at (
  487. X.I xcenter, ycenter, zcenter
  488. X) of size
  489. X(2 *
  490. X.I xsize,
  491. X2 *
  492. X.I ysize,
  493. X2 *
  494. X.I zsize
  495. X).  Although boxes must initially be aligned with the world axes,
  496. Xthey may be transformed at will.
  497. X.br
  498. X.TP
  499. X\fBsuperq \fIsurface xcenter ycenter zcenter xsize ysize zsize power\fR
  500. XCreates a superquadric with center (
  501. X.I xcenter, ycenter, zcenter,
  502. X) of total
  503. Xsize (2 *
  504. X.I xsize,
  505. X2 *
  506. X.I ysize,
  507. X2 *
  508. X.I zsize,
  509. X).
  510. X.I Power
  511. Xdefines
  512. Xhow closely the superquadric resembles the corresponding box.  The larger
  513. Xthe value of
  514. X.I power,
  515. Xthe closer it will resemble the box (with rounded corners).  A value greater
  516. Xthan or equal to one is required for reasonable images.  In addition,
  517. Xneither transparent superquadrics nor superquadrics viewed from the
  518. Xinterior will rendered correctly.
  519. X.br
  520. X.SH OBJECTS
  521. X.PP
  522. XOne key feature of
  523. X.I rayshade
  524. Xis its ability to treat groups of primitives as objects which may 
  525. Xtransformed and instantiated at will.
  526. XObjects are composed of groups of primitives and/or other objects and
  527. Xare specified in the input file as:
  528. X.nf
  529. X
  530. X    \fBdefine\fI object_name\fR
  531. X        [\fBgrid\fI xvoxels yvoxels zvoxels\fR]
  532. X        [\fBlist\fR]
  533. X        [primitives]
  534. X        [instances]
  535. X    \fBdefend\fR [texturing information]
  536. X
  537. X.fi
  538. XThe ordering of the various elements inside the object-definition block
  539. Xis inconsequential.
  540. XHere, [\fIinstances\fR]
  541. Xare any number of declarations of the form:
  542. X.TP
  543. X\fBobject \fIobject_name \fR[\fItransformations\fR] [\fItexturing information\fR]
  544. XThis causes a copy of the named object to be made, transformed and textured as
  545. Xrequested, and added to the object being defined.
  546. XAn object must be defined before it may be
  547. Xinstantiated, which ensures that no cycles appear in the object-definition
  548. Xgraph.
  549. X.PP
  550. XA special object named
  551. X.I World
  552. Xis maintained internally by 
  553. X.I rayshade.
  554. XPrimitive definitions and object instantiations which do not appear
  555. Xinside an object-definition block are added to this object.  When
  556. Xperforming raytracing, rays are intersected with the objects that make up
  557. Xthe World object.
  558. X.PP
  559. XInternally, objects are stored by one of two means.  By default,
  560. Xgroups of primitives which make up an object are stored in a \fIlist\fR.
  561. XThe constituents of such an object are stored in a simple
  562. Xlinked-list.  When a ray is intersected with such an object, the ray
  563. Xis tested for intersection with each object in the list.
  564. XWhile the \fIlist\fR is the default method of object storage, one may
  565. Xemphasize this fact in the input file by including the
  566. X.B list
  567. Xkeyword somewhere within the object-definition block.
  568. X.PP
  569. XThe second form of internal object storage is the three-dimensional \fIgrid\fR.
  570. XThe grid's total size
  571. Xis calculated by
  572. X.I rayshade
  573. Xand is equal to the bounding box of the entire object.
  574. XA grid subdivides the space in which an object lies into an array
  575. Xof uniform box-shaped
  576. X.I voxels.
  577. XEach voxel contains a linked-list of objects and primitives which
  578. Xlie within that voxel.  When intersecting a ray with an object whose
  579. Xconstituents are stored in a grid, the ray is traced incrementally from
  580. Xvoxel-to-voxel, and the ray is intersected with each object in the
  581. Xlinked list of each voxel that is visited.
  582. XIn this way
  583. Xthe intersection of a ray with a collection of objects is
  584. Xgenerally made faster at the expense of increased storage
  585. Xrequirements.
  586. X.PP
  587. XThis form of object representation is enabled by including the
  588. Xthe
  589. X.B grid
  590. Xkeyword somewhere within the object-definition block:
  591. X.TP
  592. X\fBgrid \fIxvoxels yvoxels zvoxels\fR
  593. XStores the object being defined as a grid consisting of
  594. Xa total of (xvoxels * yvoxels * zvoxels) voxels, with
  595. X.I xvoxels
  596. Xalong the x-axis of the grid,
  597. X.I yvoxels
  598. Xalong the y-axis,
  599. Xand
  600. X.I zvoxels
  601. Xalong the z-axis.  For reasonably complex objects, a value of 20 for each
  602. Xparameter usually works well.
  603. X.PP
  604. XFor convenience, one may also define surfaces inside of an object-definition
  605. Xblock.  Surfaces defined in this manner are nevertheless globally available.
  606. X.PP
  607. XIn addition, object definitions may be nested.  This facilitates the
  608. Xdefinition of objects through the use of recursive programs.
  609. X.br
  610. X.SH TRANSFORMATIONS
  611. X\fIRayshade\fR allows for the application of arbitrary linear transformations
  612. Xto primitives and compound objects.
  613. XThe specification of transformations
  614. Xoccurs immediately following the specification of a primitive or
  615. Xinstantiation of an object.
  616. XAny number of transformations may be composed; the resulting total
  617. Xtransformation is applied to the entity being transformed.  Transformations
  618. Xare specified by:
  619. X.TP
  620. X\fBtranslate \fIx y z\fR
  621. XTranslate the object by (
  622. X.IR "x, y, z" ).
  623. X.TP
  624. X\fBrotate \fIx y z theta\fR
  625. XRotate the object counter-clockwise about the vector (
  626. X.I x, y, z
  627. X) by
  628. X.I theta
  629. Xdegrees.
  630. X.TP
  631. X\fBscale \fIx y z\fR
  632. XScale the object by (
  633. X.I x, y z
  634. X).
  635. X.TP
  636. X\fBtransform \fIx1 y1 z1 x2 y2 z2 x3 y3 z3\fR
  637. XTransform the object by the column-major matrix specified by the nine
  638. Xfloating-point numbers.
  639. XThus, a point (x, y, z) on the surface of the object
  640. Xis mapped to (x*x1 + y*y1 + z*z1, x*x2 + y*y2 + z*z2, x*x3 + y*y3 + z*z3).
  641. X.br
  642. X.SH "TEXTURE MAPPING"
  643. X.PP
  644. X.I Rayshade
  645. Xprovides a means of applying solid procedural textures to surfaces of
  646. Xprimitives.  This is accomplished by supplying texture mapping information
  647. Ximmediately following the definition of a primitive, object, or instance
  648. Xof an object.  This allows one to texture individual primitives,
  649. Xobjects, and individual instances of objects at will.
  650. XTexturing information is supplied via a number of lines
  651. Xof the following form:
  652. X.TP
  653. X\fBtexture\fR \fItexture_type\fR [\fIarguments\fR] [\fItransformations\fR]
  654. X.br
  655. X.I Texture_type
  656. Xis the name of the texture to apply.
  657. X.I Arguments
  658. Xare any arguments that the specific texture type requires.
  659. XIf supplied, the indicated
  660. X.I transformations
  661. Xwill be applied to the texture.  (More accurately, the inverse of
  662. Xthe supplied transformation is applied to the point of intersection
  663. Xbefore it is passed to the texturing routines.)
  664. X.PP
  665. XVersions of Perlin's Noise() and DNoise()
  666. Xfunctions are used to generate values for
  667. Xmost of the interesting textures.
  668. XCurrently, there are seven textures available:
  669. X.TP
  670. X\fBbump\fI scale\fR
  671. Xapplies a random bump map to the surface being textured.  The point of
  672. Xintersection is passed to DNoise().  The returned normalized vector,
  673. Xweighted by
  674. X.I scale
  675. Xis added to the normal vector at the point of intersection.
  676. X.TP
  677. X\fBchecker\fI size surface\fR
  678. Xapplies a (3D) checkerboard texture to the object being textured.  Every
  679. Xpoint that falls within an "even" cube will be shaded using the characteristics
  680. Xof the named surface.  Every point that falls within an "odd" cube will
  681. Xretain its usual surface characteristics.  Be warned that strange effects
  682. Xdue to roundoff error are possible when the planar surface of an object lies
  683. Xin a plane of constant integral values in texture space.
  684. X.TP
  685. X\fBblotch \fIblend_factor surface\fR
  686. XThis texture produces a mildly interesting blotchy-looking surface.
  687. X.I Blend_factor
  688. Xis used to control the interpolation between a point's default surface
  689. Xcharacteristics and the characteristics of the named surface.  A value
  690. Xof 0 results in a roughly 50-50 mix of the two surfaces.
  691. XHigher values result in greater instances of the 'default' surface type.
  692. X.TP
  693. X\fBfbm \fIscale offset H lambda octaves thresh\fR [\fIcolormap\fR]
  694. XThis texture generates a sample of discretized fractional Brownian motion (fBm)
  695. Xand uses it to modify the diffuse component of an object's color.  If no
  696. X\fIcolormap\fR is named, the sample
  697. Xis used to scale the object's diffuse color.
  698. XIf a \fIcolormap\fR name is
  699. Xgiven, a 256-entry colormap is read from the named file, and the object
  700. Xis colored using the values in this colormap (see below).
  701. X\fIScale\fR is used to scale the output
  702. Xof the fractional Brownian motion function.  \fIOffset\fR  allows one
  703. Xto control the
  704. Xminimum value of the fBm function.  \fIH\fR is related to the
  705. X\fIHolder constant\fR
  706. Xused in the fBm (a value of 0.5 works well).  \fILambda\fR is
  707. Xused to control the \fIlacunarity\fR, or spacing between successive
  708. Xfrequencies, in the fBm (a value of 2.0 will suffice).  \fIOctaves\fR
  709. Xspecifies the number of octaves of Noise() to use in simulating the fBm (5 to 7
  710. Xworks well), and \fIthresh\fR is used to specify a lower bound on the
  711. Xoutput of fBm function.  Any value lower than \fIthresh\fR is set to zero.
  712. X.TP
  713. X\fBfbmbump \fIscale offset H lambda octaves thresh\fR
  714. XThis texture is similar to the \fBfBm\fR texture.  Rather modifying the
  715. Xcolor of a surface, \fBfBmBump\fR acts as a bump map.
  716. X.TP
  717. X\fBmarble\fR [\fIcolormap\fR]
  718. XThis texture gives a surface a marble-like appearance.  If the name of a
  719. X\fIcolormap\fR file is given, the marble will be colored using the RGB values
  720. Xin the colormap.  If no colormap name is given, the diffuse component of
  721. Xthe object's surface is simply scaled.  One may transform the texture to
  722. Xcontrol the density of the marble veins.
  723. X.TP
  724. X\fBwood\fR
  725. X.br
  726. XThis texture gives a wood-like appearance to a surface.
  727. X.PP
  728. XA colormap is an ASCII file
  729. X256 lines in length, each line containing three space-separated integers
  730. Xranging from 0 to 255.  The first number on the nth line specifies the red
  731. Xcomponent of the nth entry in the colormap, the second number the green 
  732. Xcomponent, and the third the blue.
  733. X.PP
  734. XIt is important to note that more than one texture may be applied to
  735. Xa point at any time.  In addition to being able to apply more than
  736. Xone texture directly (by supplying multiple "texturing information" lines for
  737. Xa single object), one may instantiate textured objects which, in turn,
  738. Xmay be textured or contain instances of objects which are textured, and so on.
  739. X.br
  740. X.SH "ATMOSPHERIC EFFECTS"
  741. X.PP
  742. X.I Rayshade
  743. Xhas the capability of including several kinds of atmospheric effects
  744. Xwhen rendering an image.  Currently, one such effect is available:
  745. X.TP
  746. X\fBfog\fI thinness red green blue\fR
  747. XAdd global exponential fog with the specified \fIthinness\fR and color.
  748. XFog is simulated by blending the color of the fog with the color of
  749. Xeach ray.  The amount of fog color added to a ray is a function of
  750. Xthe logarithm of the
  751. Xdistance from the ray origin to the point of intersection divided by
  752. X\fIthinness\fR.
  753. X.br
  754. X.SH "SAMPLING"
  755. X.PP
  756. XThis section clarifies how antialiasing and sampling of extended light
  757. Xsources are accomplished.  Two types of anti-aliasing are supported;  adaptive
  758. Xsubdivision and
  759. Xso-called "jittered sampling".
  760. X.PP
  761. XAdaptive subdivision works by sampling each pixel at its corners.  The contrast
  762. Xbetween these four samples is computed, and if too large, the pixel is
  763. Xsubdivided into four equivalent sub-pixels and the process is repeated.
  764. XThe threshold contrast may be controlled via the \fB-C\fR option or
  765. Xthe \fBcontrast\fR command.
  766. XThere are separate
  767. Xthresholds for the red, green, and blue channels.  If the contrast
  768. Xin any of the three is greater than the appropriate treshold value,
  769. Xthe pixel is subdivided.
  770. XThe pixel-subdivision process is repeated until either
  771. Xthe samples' contrast is less than the threshold or the maximum pixel
  772. Xsubdivision level, specified via the \fB-P\fR option or the \fBadaptive\fR
  773. Xcommand, is reached.  When
  774. Xthe subdivision process is complete, a weighted average of the samples
  775. Xis taken as the color of the pixel.
  776. X.PP
  777. XJittered sampling works by dividing each pixel into a number of square
  778. Xregions and tracing a ray through \fIsome\fR point in each region.  The
  779. Xexact location in each region is chosen randomly.  The number of regions
  780. Xinto which a pixel is subdivided is specified through the use of the
  781. X\fB-S\fR option.  The integer following this option specifies the square
  782. Xroot of the number of regions.
  783. X.PP
  784. XEach area light source is, in effect, approximated by a square grid
  785. Xof light
  786. Xsources.  The length of each side of the square is equal to the diameter
  787. Xof the extended source.
  788. XEach array element, which
  789. Xis square in shape, is in turned sampled by randomly choosing a point
  790. Xwithin that element to which a ray is traced from the point of
  791. Xintersection.
  792. XIf the ray does not intersect any primitive object before it
  793. Xstrikes a light source element, there is said to be no shadow cast
  794. Xby that portion of the light source.
  795. XThe fraction of the light emitted by an
  796. Xextended light source which reaches the point of
  797. Xintersection is the number of elements
  798. Xwhich are not blocked by
  799. Xintervening objects divided by the total number of elements.  The
  800. Xfraction is used to scale the intensity (color) of the light source, and this
  801. Xscaled intensity is then
  802. Xused in the various lighting calculations.
  803. X.PP
  804. XWhen jittered sampling is used, one shadow ray is traced to each
  805. Xextended source per shading calculation.  The element to be sampled is
  806. Xdetermined
  807. Xby the region of the pixel through which the eye ray at the top of the
  808. Xray tree passed.
  809. X.PP
  810. XWhen adaptive supersampling is used, the \fB-S\fR option or the
  811. X\fBsamples\fR command controls how
  812. Xmay shadow rays are traced to each extended extended light source
  813. Xper shading calculation.
  814. XSpecifically,
  815. Xeach extended source is approximated by a square array consisting
  816. Xof \fIsamples\fR * \fIsamples\fR elements.  However,
  817. Xthe corners of the array are skipped to save rendering time and
  818. Xto more closely approximate the circular projection of an extended light
  819. Xsource.  Because the corners are
  820. Xskipped,  \fIsamples\fR must be at least 3 if adaptive supersampling is
  821. Xbeing used.
  822. X.PP
  823. XNot that the meaning of the \fB-S\fR option (and the \fBsamples\fR
  824. Xcommand) is different depending upon
  825. Xwhether or not jittered
  826. Xsampling is being used.
  827. X.PP
  828. XWhile jittered sampling is generally
  829. Xslower than adaptive subdivision, it can be beneficial if the penumbrae
  830. Xcast by extended light sources take up a relatively large percentage
  831. Xof the entire image or if the image is especially prone to aliasing.
  832. X.SH EXAMPLES
  833. XA very simple
  834. X.I rayshade
  835. Xinput file might be:
  836. X.nf
  837. X.IN +8
  838. X
  839. Xlight 1.0 directional 1. 1. 1.
  840. X
  841. Xsurface red  .2 0 0  .8 0 0  .5 .5 .5  32. 0.8 0. 1.
  842. Xsurface green  0 .2 0  0 .8 0  0 0 0  0. 0. 0. 1.
  843. X
  844. Xsphere red 8.  0. 0. -2.
  845. Xplane green 0. 0. 1.  0. 0. -10.
  846. X
  847. X.IN -8
  848. X.fi
  849. X.PP
  850. XPassing this file to
  851. X.I rayshade
  852. Xwill result in an image of a red reflective sphere sitting on a white
  853. Xground-plane being written to the standard output.  Note that in this case,
  854. Xdefault values for
  855. X.B
  856. Xeyep, lookp, up, screen, fov,
  857. Xand
  858. X.B background
  859. Xare assumed.
  860. X.PP
  861. XA more interesting example uses instantiation to place multiple copies
  862. Xof an object at various locations in world space:
  863. X.nf
  864. X.IN +8
  865. X
  866. Xeyep 10. 10. 10.
  867. Xfov 20
  868. Xlight 1.0 directional 0. 1. 1.
  869. Xsurface red  .2 0 0  .8 0 0  .5 .5 .5  32. 0.8 0. 1.
  870. Xsurface green  0 .2 0  0 .8 0  0 0 0  0. 0. 0. 1.
  871. Xsurface white 0.1 0.1 0.1 0.8 0.8 0.8 0.6 0.6 0.6 30 0 0 0
  872. X
  873. Xdefine blob
  874. X    sphere red 0.5   .5 .5 0.
  875. X    sphere white 0.5 .5 -.5 0. texture marble scale 0.5 0.5 0.5
  876. X    sphere red 0.5  -.5 -.5 0.
  877. X    sphere green 0.5 -.5 .5 0.
  878. Xdefend
  879. X
  880. Xobject blob translate 1. 1. 0.
  881. Xobject blob translate 1. -1. 0.
  882. Xobject blob translate -1. -1. 0.
  883. Xobject blob translate -1. 1. 0.
  884. Xgrid 20 20 20
  885. X
  886. X.IN -8
  887. X.fi
  888. X.PP
  889. XHere, an object named
  890. X.I blob
  891. Xis defined to consist of four spheres, two of which are red and reflective.
  892. XThe object is stored as a simple list of the four spheres.
  893. XThe
  894. X.I World
  895. Xobject consists of four instances of this object, translated to place
  896. Xthem in a regular pattern about the origin.  Note that since the marbled
  897. Xsphere was textured in "sphere space" each instance of that particular sphere
  898. Xhas exactly the same marble texture applied to it.
  899. X.PP
  900. XOf course, just as the object 
  901. X.I blob
  902. Xwas instantiated as part of the
  903. X.I World
  904. Xobject, one may instantiate objects as part of any other object.  For
  905. Xexample, a series of objects such as:
  906. X.nf
  907. X    define wheel
  908. X        sphere tire_color 1.  0 0 0  scale 1. 0.2 1.
  909. X        sphere hub_color 0.2 0 0. 0
  910. X    defend
  911. X
  912. X    define axle
  913. X        object wheel translate 0. 2. 0.
  914. X        object wheel translate 0. -2. 0.
  915. X        cylinder axle_color 0. -2. 0. 0. 2. 0. 0.1
  916. X    defend
  917. X
  918. X    define truck
  919. X        box truck_color 0. 0. 0. 5. 2. 2.    /* Trailer */
  920. X        box truck_color 6. 0 -1 2 2 1        /* Cab */
  921. X        object axle translate -4 0 -2
  922. X        object axle translate 4. 0. -2.
  923. X    defend
  924. X
  925. X.fi
  926. Xcould be used to define a very primitive truck-like object.
  927. X.br
  928. X.SH "MINIMIZING RAYTRACING TIME"
  929. X.PP
  930. XRay tracing is a computationally intensive process, and rendering
  931. Xcomplex scenes can take hours of CPU time, even on relatively powerful
  932. Xmachines.  There are, however, a number of ways of attempting to reduce the
  933. Xrunning time of the program.
  934. X.PP
  935. XThe first and most obvious way is to reduce the number of rays which
  936. Xare traced.  This is most simply accomplished by reducing the resolution
  937. Xof the image to be rendered.  The
  938. X.B \-P
  939. Xoption may be used to reduce the maximum pixel subdivision level.
  940. XA maximum level of 0 will speed raytracing up considerably, but will result
  941. Xin obvious aliasing in the image.  By default, a pixel will be subdivided
  942. Xa maximum of one time, giving a maximum of nine rays per pixel total.
  943. X.PP 
  944. XAlternatively, the
  945. X\fB-C\fR option or the \fBcontrast\fR command 
  946. Xmay be used to decrease the number of instances in which
  947. Xpixels are subdivided.  Using these options, one may indicate the maximum
  948. Xnormalized contrast which is allowed before supersampling will occur.  If the
  949. Xred, green or blue contrast between neighboring samples (taken at pixel corners)
  950. Xis greater than the maximum allowed, the pixel will be subdivided into
  951. Xfour sub-pixels and the sampling process will recurse until the sub-pixel
  952. Xcontrast is acceptable or the maximum subdivision level
  953. Xis reached.
  954. X.PP
  955. XThe number of rays traced can also be lowered by
  956. Xmaking all surfaces non-reflecting and non-refracting or by
  957. Xsetting
  958. X.B maxdepth
  959. Xto a small number.  If set to 0, no reflection or
  960. Xrefraction rays will be traced. 
  961. XLastly, removing all light sources
  962. Xwill cause no shadow rays to be traced, but will result in a flat-looking
  963. Ximage.
  964. X.PP
  965. XIn addition, judicious use of the \fBgrid\fR command can reduce rendering
  966. Xtimes substantially.
  967. XHowever, if an object consists of a relatively small number of simple objects,
  968. Xit will likely take less time to simply check for intersection with
  969. Xeach element of the object than to trace a ray through a grid.
  970. X.br
  971. X.SH FILES
  972. X.nf
  973. XExamples/*                example input files
  974. X.fi
  975. X.br
  976. X.SH "AUTHORS"
  977. X.I Rayshade
  978. Xhad its beginnings as an
  979. X"introductory" public-domain
  980. Xraytracer written by Roman Kuchkuda.  Vestiges of his code may be found
  981. Xin rayshade, particularly in the names of variables and the superquadric
  982. Xcode.
  983. XThe first version of
  984. X.I rayshade
  985. Xwas written at Princeton University during 1987-88
  986. Xby Craig Kolb, David C. Hoffman, and David P. Dobkin.
  987. XThe current manifestation of
  988. X.I rayshade
  989. Xwas written during the fall of 1988 by Craig Kolb.
  990. XThe Noise() and DNoise() routines which form the basis of many
  991. Xof the texturing functions were written by Robert Skinner and Ken
  992. XMusgrave.
  993. X.br
  994. X.SH "CAVEATS"
  995. X.PP
  996. X.I Rayshade
  997. Xperforms no automatic hierarchy construction.  The intelligent placement
  998. Xof objects in grids and/or lists is entirely the job of the modeler.
  999. X.PP
  1000. XWhile transparent objects may be wholly contained in other transparent
  1001. Xobjects, rendering partially intersecting transparent objects with
  1002. Xdifferent indices of refraction is, for the most part, nonsensical.
  1003. X.PP
  1004. X.I Rayshade
  1005. Xis capable of using large amounts of memory.  In the environment in
  1006. Xwhich it was developed (machines with at least 8 Megabytes
  1007. Xof physical memory plus virtual memory), this has not been a problem,
  1008. Xand scenes containing several billion primitives have been
  1009. Xrendered.  On smaller machines, however, memory size can be a limiting factor.
  1010. X.PP
  1011. XThe "Total memory allocated" statistic is the total space allocated by
  1012. Xcalls to malloc.  It is \fInot\fR the memory high-water mark.  After
  1013. Xthe input file is processed, memory is only allocated when refraction
  1014. Xoccurs (to push media onto a stack) and when raytracing height fields
  1015. X(to dynamically allocate triangles).
  1016. X.PP
  1017. XThe image produced will always be 24 bits deep.
  1018. X.PP
  1019. XExplicit or implicit specification of vectors of length
  1020. Xless than \fIepsilon\fR (1.E-6) results in undefined behavior.
  1021. X.br
  1022. X.SH "SEE ALSO"
  1023. Xrle(5)
  1024. END_OF_FILE
  1025. if test 35763 -ne `wc -c <'doc/rayshade.1'`; then
  1026.     echo shar: \"'doc/rayshade.1'\" unpacked with wrong size!
  1027. fi
  1028. # end of 'doc/rayshade.1'
  1029. fi
  1030. echo shar: End of archive 8 \(of 8\).
  1031. cp /dev/null ark8isdone
  1032. MISSING=""
  1033. for I in 1 2 3 4 5 6 7 8 ; do
  1034.     if test ! -f ark${I}isdone ; then
  1035.     MISSING="${MISSING} ${I}"
  1036.     fi
  1037. done
  1038. if test "${MISSING}" = "" ; then
  1039.     echo You have unpacked all 8 archives.
  1040.     rm -f ark[1-9]isdone
  1041. else
  1042.     echo You still need to unpack the following archives:
  1043.     echo "        " ${MISSING}
  1044. fi
  1045. ##  End of shell archive.
  1046. exit 0
  1047.