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

  1. Subject:  v21i018:  A ray tracing program, Patch3
  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 18
  8. Archive-name: rayshade/patch3
  9.  
  10. System: rayshade version 3.0
  11. Patch #: 3
  12. Priority: MEDIUM
  13. Subject: Patch #2, continued.
  14.  
  15. Fix:    From rn, say "| patch -p -N -d DIR", where DIR is your rayshade source
  16.     directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
  17.     If you don't have the patch program, apply the following by hand,
  18.     or get patch (version 2.0, latest patchlevel).
  19.  
  20.     After patching:
  21.         make depend
  22.         make
  23.  
  24.     If patch indicates that patchlevel is the wrong version, you may need
  25.     to apply one or more previous patches, or the patch may already
  26.     have been applied.  See the patchlevel.h file to find out what has or
  27.     has not been applied.  In any event, don't continue with the patch.
  28.  
  29.  
  30. Index: src/patchlevel.h
  31. Prereq: 2
  32. 1c1
  33. < #define PATCHLEVEL 2
  34. ---
  35. > #define PATCHLEVEL 3
  36.  
  37. Index: src/voxels.c
  38. *** src/voxels.c.old    Thu Dec  7 23:21:58 1989
  39. --- src/voxels.c    Thu Dec  7 23:21:59 1989
  40. ***************
  41. *** 18,26 ****
  42.    * name of the person performing the modification, the date of modification,
  43.    * and the reason for such modification.
  44.    *
  45. !  * $Id: voxels.c,v 3.0 89/10/27 02:06:09 craig Exp $
  46.    *
  47.    * $Log:    voxels.c,v $
  48.    * Revision 3.0  89/10/27  02:06:09  craig
  49.    * Baseline for first official release.
  50.    * 
  51. --- 18,29 ----
  52.    * name of the person performing the modification, the date of modification,
  53.    * and the reason for such modification.
  54.    *
  55. !  * $Id: voxels.c,v 3.0.1.1 89/12/06 16:33:29 craig Exp $
  56.    *
  57.    * $Log:    voxels.c,v $
  58. +  * Revision 3.0.1.1  89/12/06  16:33:29  craig
  59. +  * patch2: Added calls to new error/warning routines.
  60. +  * 
  61.    * Revision 3.0  89/10/27  02:06:09  craig
  62.    * Baseline for first official release.
  63.    * 
  64. ***************
  65. *** 89,95 ****
  66.            * in case...
  67.            */
  68.           make_unbounded(obj, grid);
  69. !         fprintf(stderr,"Strange, engrid got an unbounded object...\n");
  70.           return;
  71.           }
  72.   
  73. --- 92,98 ----
  74.            * in case...
  75.            */
  76.           make_unbounded(obj, grid);
  77. !         RSwarning("Strange, engrid got an unbounded object...\n");
  78.           return;
  79.           }
  80.   
  81. Index: doc/rayshade.1
  82. *** doc/rayshade.1.old    Thu Dec  7 23:18:57 1989
  83. --- doc/rayshade.1    Thu Dec  7 23:19:01 1989
  84. ***************
  85. *** 1,8 ****
  86.   .\" Manual page for rayshade, 'troff -man' format.
  87.   .\"
  88. ! .\" $Id: rayshade.1,v 3.0.1.1 89/11/17 16:57:19 craig Exp Locker: craig $
  89.   .\"
  90.   .\" $Log:    rayshade.1,v $
  91.   .\" Revision 3.0.1.1  89/11/17  16:57:19  craig
  92.   .\" patch1: Documented new -w option.
  93.   .\" 
  94. --- 1,38 ----
  95.   .\" Manual page for rayshade, 'troff -man' format.
  96.   .\"
  97. ! .\" $Id: rayshade.1,v 3.0.1.11 89/12/06 17:21:39 craig Exp $
  98.   .\"
  99.   .\" $Log:    rayshade.1,v $
  100. + .\" Revision 3.0.1.11  89/12/06  17:21:39  craig
  101. + .\" patch2: Added suggestion to use cpp.
  102. + .\" 
  103. + .\" Revision 3.0.1.10  89/12/06  16:42:54  craig
  104. + .\" patch2: Removed documentation of #include handling.
  105. + .\" 
  106. + .\" Revision 3.0.1.9  89/12/03  17:59:43  craig
  107. + .\" patch2: More typos...
  108. + .\" 
  109. + .\" Revision 3.0.1.8  89/12/02  19:52:04  craig
  110. + .\" patch2: General cleanup.
  111. + .\" 
  112. + .\" Revision 3.0.1.7  89/12/02  16:48:37  craig
  113. + .\" patch2: Documented -F option.
  114. + .\" 
  115. + .\" Revision 3.0.1.6  89/12/02  15:10:09  craig
  116. + .\" patch2: Fixed various typos, credited depth of field code.
  117. + .\" 
  118. + .\" Revision 3.0.1.5  89/12/02  14:36:44  craig
  119. + .\" patch2: Documented "aperture" and "focaldist".
  120. + .\" 
  121. + .\" Revision 3.0.1.4  89/11/27  18:44:19  craig
  122. + .\" patch2: Expanded and corrected the documentation of colormaps.
  123. + .\" 
  124. + .\" Revision 3.0.1.3  89/11/27  18:06:32  craig
  125. + .\" patch2: Documented mist, corrected fog documentation & various typos.
  126. + .\" 
  127. + .\" Revision 3.0.1.2  89/11/27  15:20:49  craig
  128. + .\" patch2: Corrected heightfield documentation.
  129. + .\" 
  130.   .\" Revision 3.0.1.1  89/11/17  16:57:19  craig
  131.   .\" patch1: Documented new -w option.
  132.   .\" 
  133. ***************
  134. *** 14,20 ****
  135.   .TH RAYSHADE  1G "September 11, 1989"
  136.   .UC 4
  137.   .SH NAME
  138. ! rayshade \- a raytracing program
  139.   .SH SYNOPSIS
  140.   .B rayshade
  141.   [
  142. --- 44,50 ----
  143.   .TH RAYSHADE  1G "September 11, 1989"
  144.   .UC 4
  145.   .SH NAME
  146. ! rayshade \- a ray tracing program
  147.   .SH SYNOPSIS
  148.   .B rayshade
  149.   [
  150. ***************
  151. *** 25,31 ****
  152.   .SH DESCRIPTION
  153.   .I Rayshade
  154.   reads a file describing a scene to be rendered and produces a
  155. ! Utah Raster RLE format file of the raytraced image.
  156.   .br
  157.   .SH OPTIONS
  158.   .TP
  159. --- 55,61 ----
  160.   .SH DESCRIPTION
  161.   .I Rayshade
  162.   reads a file describing a scene to be rendered and produces a
  163. ! Utah Raster RLE format file of the ray-traced image.
  164.   .br
  165.   .SH OPTIONS
  166.   .TP
  167. ***************
  168. *** 38,43 ****
  169. --- 68,76 ----
  170.   .B \-E \fIeye_separation\fR
  171.   Set eye separation for stereo imaging.
  172.   .TP
  173. + .B \-F \fIreport_freq\fR
  174. + Set frequency, in lines, of status report (default 10).
  175. + .TP
  176.   .B \-h
  177.   Print a short usage message.
  178.   .TP
  179. ***************
  180. *** 87,110 ****
  181.   .B \-v
  182.   Write verbose output to standard output.
  183.   .TP
  184. - .B \-w
  185. - Write verbose worker information to the standard error.
  186. - .TP
  187.   .B \-W \fIworkers\fR
  188. ! Specify number of worker processes (Linda implementation only).
  189.   .br
  190.   .SH OVERVIEW
  191.   .PP
  192.   .I Rayshade
  193. ! is an raytracer capable of raytracing images of objects composed
  194.   of a large number of primitive objects.
  195. ! .I Rayhade
  196.   reads a series of lines supplied on the standard input or contained
  197.   in the file named on the command line.
  198.   After reading the input file,
  199.   .I rayshade
  200. ! raytraces the image from
  201. ! the bottom upwards.  As each scanline is traced, pixels are written to
  202.   a Utah Raster RLE format image file.  By default, this image file is written
  203.   to the standard output, and
  204.   information messages and statistics
  205. --- 120,142 ----
  206.   .B \-v
  207.   Write verbose output to standard output.
  208.   .TP
  209.   .B \-W \fIworkers\fR
  210. ! Specify number of worker processes (Linda version only).
  211. ! .TP
  212. ! .B \-w
  213. ! Write verbose worker information to the standard error (Linda version only).
  214.   .br
  215.   .SH OVERVIEW
  216.   .PP
  217.   .I Rayshade
  218. ! is an ray tracer capable of rendering images composed
  219.   of a large number of primitive objects.
  220. ! .I Rayshade
  221.   reads a series of lines supplied on the standard input or contained
  222.   in the file named on the command line.
  223.   After reading the input file,
  224.   .I rayshade
  225. ! renders the image.  As each scanline is rendered, pixels are written to
  226.   a Utah Raster RLE format image file.  By default, this image file is written
  227.   to the standard output, and
  228.   information messages and statistics
  229. ***************
  230. *** 125,138 ****
  231.   and range from 0
  232.   (zero intensity) to 1. (full intensity).
  233.   .PP
  234. - A
  235. - .B #include
  236. - directive is supported which, as in the C language,
  237. - causes the contents of the quoted filename which follows to be read and
  238. - effectively inserted at that point in the input file.  Be warned that
  239. - .I rayshade
  240. - does no checking for mutual or recursive inclusion of files.
  241. - .PP
  242.   The following sections describe the keywords which may be included
  243.   in the input file.  Items in boldface type are literals, while 
  244.   square brackets surround optional items.
  245. --- 157,162 ----
  246. ***************
  247. *** 173,179 ****
  248.   "-R 128 128" on the command line.
  249.   .TP
  250.   \fBscreen \fIx_resolution y_resolution\fR
  251. ! Specifies the horizontal and vertical resolution of the image to be traced.
  252.   This command may be overridden through use of
  253.   the \fB-R\fR option.
  254.   The default resolution
  255. --- 197,203 ----
  256.   "-R 128 128" on the command line.
  257.   .TP
  258.   \fBscreen \fIx_resolution y_resolution\fR
  259. ! Specifies the horizontal and vertical resolution of the image to be rendered.
  260.   This command may be overridden through use of
  261.   the \fB-R\fR option.
  262.   The default resolution
  263. ***************
  264. *** 190,195 ****
  265. --- 214,245 ----
  266.   By default, the image is written to the standard output.
  267.   This command may be overridden through the use of the \fB-O\fR option.
  268.   .TP
  269. + \fBaperture \fIaperture_radius\fR
  270. + The \fIaperture_radius\fR is the radius, in world units, of the aperture
  271. + centered at the eye point.
  272. + This controls,
  273. + in conjunction with \fBfocaldist\fR, the depth of field,
  274. + and thus the amount of focus blur present in the final image.
  275. + Rays are cast from various places on the
  276. + aperture disk towards a point which is
  277. + \fIfocal_distance\fR units from the center of the aperture disk.
  278. + This causes objects which are \fIfocal_distance\fR units from the eye point
  279. + to be in sharp focus.  Note that an 
  280. + \fIaperture_radius\fR of zero causes a pinhole camera model to be used,
  281. + and there will be no blurring (this is the default).  Increasing the
  282. + aperture radius leads to increased blurring.  When using
  283. + a non-zero aperture radius, it is best to use jittered sampling in order to
  284. + reduce aliasing effects.
  285. + .TP
  286. + \fBfocaldist \fIfocal_distance\fR
  287. + Specifies the distance, in world units, from the eye point to the
  288. + focal plane.  Points which lie in this plane will always be in
  289. + sharp focus.  By keeping
  290. + \fIaperture_radius\fR constant and changing \fIfocal_distance\fR, it is
  291. + possible to create a sequence of frames which simulate pulling focus.
  292. + By default, \fIfocal_distance\fR is equal to the distance from the eye point
  293. + to the look point.
  294. + .TP
  295.   \fBmaxdepth \fImaximum_depth\fR
  296.   Controls the maximum depth of the ray tree.  The default is 3, with eye
  297.   rays considered to be of depth zero.
  298. ***************
  299. *** 217,226 ****
  300.   \fBsamples \fInum_samples\fR
  301.   Specifies the number of jittered samples.  See SAMPLING for details.
  302.   When specified, this value may be overridden through the use of the
  303. ! \fB-S\fR option.  The default value is three.
  304.   .TP
  305.   \fBcontrast \fIred green blue\fR
  306. ! Specifies the maximum allowed contrast between samples in a (sub)pixel
  307.   before subdivision takes place.  See SAMPLING for details.
  308.   When specified in the input file, these
  309.   values may be overridden through the use of the \fB-C\fR option.  The
  310. --- 267,276 ----
  311.   \fBsamples \fInum_samples\fR
  312.   Specifies the number of jittered samples.  See SAMPLING for details.
  313.   When specified, this value may be overridden through the use of the
  314. ! \fB-S\fR option.  The default value is 3.
  315.   .TP
  316.   \fBcontrast \fIred green blue\fR
  317. ! Specifies the maximum contrast allowed between samples in a (sub)pixel
  318.   before subdivision takes place.  See SAMPLING for details.
  319.   When specified in the input file, these
  320.   values may be overridden through the use of the \fB-C\fR option.  The
  321. ***************
  322. *** 233,239 ****
  323.   Point sources are specified by a location in world-space
  324.   and produce shadows with sharp edges.  Extended sources are specified
  325.   by a location and a radius.  They produce shadows with "fuzzy" edges
  326. ! (penumbrae), but increase ray-tracing time considerably.  Directional
  327.   sources are specified by a direction.
  328.   A maximum of 10 light sources may be defined.
  329.   .PP
  330. --- 283,289 ----
  331.   Point sources are specified by a location in world-space
  332.   and produce shadows with sharp edges.  Extended sources are specified
  333.   by a location and a radius.  They produce shadows with "fuzzy" edges
  334. ! (penumbrae), but increase ray tracing time considerably.  Directional
  335.   sources are specified by a direction.
  336.   A maximum of 10 light sources may be defined.
  337.   .PP
  338. ***************
  339. *** 262,268 ****
  340.   time is increased substantially.  Rather than tracing one shadow
  341.   ray to a light source, multiple rays
  342.   are traced to various points on the extended source.  The extended source
  343. ! is approximated by sampling a square grid light sources.
  344.   See SAMPLING for more details on the
  345.   sampling of extended light sources.
  346.   .TP
  347. --- 312,318 ----
  348.   time is increased substantially.  Rather than tracing one shadow
  349.   ray to a light source, multiple rays
  350.   are traced to various points on the extended source.  The extended source
  351. ! is approximated by sampling a square grid of light sources.
  352.   See SAMPLING for more details on the
  353.   sampling of extended light sources.
  354.   .TP
  355. ***************
  356. *** 302,311 ****
  357.   specify the diffuse color of the surface.  This color, the
  358.   .I brightness
  359.   component of each light source whose light strikes the surface, and
  360. ! dot product of the incoming ray and the surface normal at the point of
  361.   intersection
  362. ! determine the color which is added to the color of the ray striking
  363. ! the surface.
  364.   .PP
  365.   .I Sr, sg
  366.   and
  367. --- 352,360 ----
  368.   specify the diffuse color of the surface.  This color, the
  369.   .I brightness
  370.   component of each light source whose light strikes the surface, and
  371. ! dot product of the incident ray and the surface normal at the point of
  372.   intersection
  373. ! determine the color which is added to the color of the incident ray.
  374.   .PP
  375.   .I Sr, sg
  376.   and
  377. ***************
  378. *** 330,336 ****
  379.   a reflection ray. The color assigned to that ray will be scaled
  380.   by
  381.   .I refl
  382. ! and added to the color of the surface.
  383.   .PP
  384.   .I Transp
  385.   is
  386. --- 379,385 ----
  387.   a reflection ray. The color assigned to that ray will be scaled
  388.   by
  389.   .I refl
  390. ! and added to the color of the incident ray.
  391.   .PP
  392.   .I Transp
  393.   is
  394. ***************
  395. *** 337,347 ****
  396.   a floating-point number between 0 and 1
  397.   which indicates the transparency of the object.  If non-zero,
  398.   a ray striking the surface will spawn a ray which is transmitted through
  399. ! the object,
  400. ! and the resulting color of this ray is scaled by
  401. ! .I transp
  402. ! and added to
  403. ! the color of the surface.  The direction of the refraction
  404.   ray is controlled by the
  405.   .I index
  406.   parameter, which indicates the index of refraction of
  407. --- 386,395 ----
  408.   a floating-point number between 0 and 1
  409.   which indicates the transparency of the object.  If non-zero,
  410.   a ray striking the surface will spawn a ray which is transmitted through
  411. ! the object.
  412. ! The resulting color of this transmitted ray is scaled by
  413. ! \fItransp\fR and added to the
  414. ! color of the incident ray.  The direction of the transmitted
  415.   ray is controlled by the
  416.   .I index
  417.   parameter, which indicates the index of refraction of
  418. ***************
  419. *** 365,373 ****
  420.   .br
  421.   .SH PRIMITIVES
  422.   .PP
  423. ! The raytracer is capable of rendering a number of primitive objects.
  424.   Primitives may be specified inside of an object-definition block, in
  425. ! which case it is added to the list of primitives belonging to that
  426.   object. In addition, primitives may be defined
  427.   outside of object-definition blocks.  Primitives such as these are
  428.   added to the list of primitives belonging to the World object.  See
  429. --- 413,421 ----
  430.   .br
  431.   .SH PRIMITIVES
  432.   .PP
  433. ! The ray tracer is capable of rendering a number of primitive objects.
  434.   Primitives may be specified inside of an object-definition block, in
  435. ! which case they are added to the list of primitives belonging to that
  436.   object. In addition, primitives may be defined
  437.   outside of object-definition blocks.  Primitives such as these are
  438.   added to the list of primitives belonging to the World object.  See
  439. ***************
  440. *** 379,385 ****
  441.   to this rule are transparent primitives, for which rayshade uses the
  442.   dot product of the normal and the incident ray to determine if the ray
  443.   is entering or exiting the surface, and superquadrics, whose normals
  444. ! are never modified due to the nature of the ray/superquadric interesection
  445.   code.  Thus, all non-transparent primitives except superquadrics will in
  446.   effect be double-sided.
  447.   .PP
  448. --- 427,433 ----
  449.   to this rule are transparent primitives, for which rayshade uses the
  450.   dot product of the normal and the incident ray to determine if the ray
  451.   is entering or exiting the surface, and superquadrics, whose normals
  452. ! are never modified due to the nature of the ray/superquadric intersection
  453.   code.  Thus, all non-transparent primitives except superquadrics will in
  454.   effect be double-sided.
  455.   .PP
  456. ***************
  457. *** 454,468 ****
  458.   while the top will have radius
  459.   .I top_radius.
  460.   .TP
  461. ! \fBheightfield \fIfilename\fR
  462.   Reads height field data from \fIfilename\fR and creates a height square
  463.   height field of unit size centered at (0.5, 0.5).  The binary data in
  464.   \fIfilename\fR
  465.   is stored as an initial integer giving the square root of number of data
  466. ! points in the file, followed by the data stored as floating-point
  467.   numbers.  The height field is rendered as a surface tessellated by triangles.
  468.   Non-square height fields may be rendered by setting vertex heights to
  469. ! less than or equal to -1000.  Triangles which have all vertices less than
  470.   or equal in altitude to this value are not rendered.
  471.   .TP
  472.   \fBbox \fIsurface xcenter ycenter zcenter xsize ysize zsize\fR
  473. --- 502,516 ----
  474.   while the top will have radius
  475.   .I top_radius.
  476.   .TP
  477. ! \fBheightfield \fIsurface filename\fR
  478.   Reads height field data from \fIfilename\fR and creates a height square
  479.   height field of unit size centered at (0.5, 0.5).  The binary data in
  480.   \fIfilename\fR
  481.   is stored as an initial integer giving the square root of number of data
  482. ! points in the file, followed by altitude (Z) values stored as floating-point
  483.   numbers.  The height field is rendered as a surface tessellated by triangles.
  484.   Non-square height fields may be rendered by setting vertex heights to
  485. ! less than or equal to -1000.  Triangles which have any vertex less than
  486.   or equal in altitude to this value are not rendered.
  487.   .TP
  488.   \fBbox \fIsurface xcenter ycenter zcenter xsize ysize zsize\fR
  489. ***************
  490. *** 496,502 ****
  491.   the value of
  492.   .I power,
  493.   the closer it will resemble the box (with rounded corners).  A value greater
  494. ! than or equal to one is required for reasonable images.  In addition,
  495.   neither transparent superquadrics nor superquadrics viewed from the
  496.   interior will rendered correctly.
  497.   .br
  498. --- 544,550 ----
  499.   the value of
  500.   .I power,
  501.   the closer it will resemble the box (with rounded corners).  A value greater
  502. ! than or equal to 1 is required for reasonable images.  In addition,
  503.   neither transparent superquadrics nor superquadrics viewed from the
  504.   interior will rendered correctly.
  505.   .br
  506. ***************
  507. *** 536,542 ****
  508.   .I rayshade.
  509.   Primitive definitions and object instantiations which do not appear
  510.   inside an object-definition block are added to this object.  When
  511. ! performing raytracing, rays are intersected with the objects that make up
  512.   the World object.
  513.   .PP
  514.   Internally, objects are stored by one of two means.  By default,
  515. --- 584,590 ----
  516.   .I rayshade.
  517.   Primitive definitions and object instantiations which do not appear
  518.   inside an object-definition block are added to this object.  When
  519. ! performing ray tracing, rays are intersected with the objects that make up
  520.   the World object.
  521.   .PP
  522.   Internally, objects are stored by one of two means.  By default,
  523. ***************
  524. *** 544,550 ****
  525.   The constituents of such an object are stored in a simple
  526.   linked-list.  When a ray is intersected with such an object, the ray
  527.   is tested for intersection with each object in the list.
  528. ! While the \fIlist\fR is the default method of object storage, one may
  529.   emphasize this fact in the input file by including the
  530.   .B list
  531.   keyword somewhere within the object-definition block.
  532. --- 592,598 ----
  533.   The constituents of such an object are stored in a simple
  534.   linked-list.  When a ray is intersected with such an object, the ray
  535.   is tested for intersection with each object in the list.
  536. ! While the list is the default method of object storage, one may
  537.   emphasize this fact in the input file by including the
  538.   .B list
  539.   keyword somewhere within the object-definition block.
  540. ***************
  541. *** 553,566 ****
  542.   The grid's total size
  543.   is calculated by
  544.   .I rayshade
  545. ! and is equal to the bounding box of the entire object.
  546.   A grid subdivides the space in which an object lies into an array
  547.   of uniform box-shaped
  548.   .I voxels.
  549.   Each voxel contains a linked-list of objects and primitives which
  550. ! lie within that voxel.  When intersecting a ray with an object whose
  551. ! constituents are stored in a grid, the ray is traced incrementally from
  552. ! voxel-to-voxel, and the ray is intersected with each object in the
  553.   linked list of each voxel that is visited.
  554.   In this way
  555.   the intersection of a ray with a collection of objects is
  556. --- 601,614 ----
  557.   The grid's total size
  558.   is calculated by
  559.   .I rayshade
  560. ! and is equal to the bounding box of the object that is engridded.
  561.   A grid subdivides the space in which an object lies into an array
  562.   of uniform box-shaped
  563.   .I voxels.
  564.   Each voxel contains a linked-list of objects and primitives which
  565. ! lie within that voxel.  When intersecting a ray with an object which
  566. ! is stored in a grid, the ray is traced incrementally from
  567. ! voxel-to-voxel, and the ray is tested for intersected against each object in the
  568.   linked list of each voxel that is visited.
  569.   In this way
  570.   the intersection of a ray with a collection of objects is
  571. ***************
  572. *** 652,661 ****
  573.   .TP
  574.   \fBbump\fI scale\fR
  575.   applies a random bump map to the surface being textured.  The point of
  576. ! intersection is passed to DNoise().  The returned normalized vector,
  577.   weighted by
  578.   .I scale
  579. ! is added to the normal vector at the point of intersection.
  580.   .TP
  581.   \fBchecker\fI size surface\fR
  582.   applies a (3D) checkerboard texture to the object being textured.  Every
  583. --- 700,709 ----
  584.   .TP
  585.   \fBbump\fI scale\fR
  586.   applies a random bump map to the surface being textured.  The point of
  587. ! intersection is passed to DNoise().  The returned normalized vector is
  588.   weighted by
  589.   .I scale
  590. ! and added to the normal vector at the point of intersection.
  591.   .TP
  592.   \fBchecker\fI size surface\fR
  593.   applies a (3D) checkerboard texture to the object being textured.  Every
  594. ***************
  595. *** 663,669 ****
  596.   of the named surface.  Every point that falls within an "odd" cube will
  597.   retain its usual surface characteristics.  Be warned that strange effects
  598.   due to roundoff error are possible when the planar surface of an object lies
  599. ! in a plane of constant integral values in texture space.
  600.   .TP
  601.   \fBblotch \fIblend_factor surface\fR
  602.   This texture produces a mildly interesting blotchy-looking surface.
  603. --- 711,717 ----
  604.   of the named surface.  Every point that falls within an "odd" cube will
  605.   retain its usual surface characteristics.  Be warned that strange effects
  606.   due to roundoff error are possible when the planar surface of an object lies
  607. ! in a plane of constant integral value in texture space.
  608.   .TP
  609.   \fBblotch \fIblend_factor surface\fR
  610.   This texture produces a mildly interesting blotchy-looking surface.
  611. ***************
  612. *** 675,682 ****
  613.   .TP
  614.   \fBfbm \fIscale offset H lambda octaves thresh\fR [\fIcolormap\fR]
  615.   This texture generates a sample of discretized fractional Brownian motion (fBm)
  616. ! and uses it to modify the diffuse component of an object's color.  If no
  617. ! \fIcolormap\fR is named, the sample
  618.   is used to scale the object's diffuse color.
  619.   If a \fIcolormap\fR name is
  620.   given, a 256-entry colormap is read from the named file, and the object
  621. --- 723,730 ----
  622.   .TP
  623.   \fBfbm \fIscale offset H lambda octaves thresh\fR [\fIcolormap\fR]
  624.   This texture generates a sample of discretized fractional Brownian motion (fBm)
  625. ! and uses it to modify the diffuse and ambient components of an object's color.
  626. ! If no \fIcolormap\fR is named, the sample
  627.   is used to scale the object's diffuse color.
  628.   If a \fIcolormap\fR name is
  629.   given, a 256-entry colormap is read from the named file, and the object
  630. ***************
  631. *** 694,707 ****
  632.   output of fBm function.  Any value lower than \fIthresh\fR is set to zero.
  633.   .TP
  634.   \fBfbmbump \fIscale offset H lambda octaves thresh\fR
  635. ! This texture is similar to the \fBfBm\fR texture.  Rather modifying the
  636. ! color of a surface, \fBfBmBump\fR acts as a bump map.
  637.   .TP
  638.   \fBmarble\fR [\fIcolormap\fR]
  639.   This texture gives a surface a marble-like appearance.  If the name of a
  640.   \fIcolormap\fR file is given, the marble will be colored using the RGB values
  641. ! in the colormap.  If no colormap name is given, the diffuse component of
  642. ! the object's surface is simply scaled.  One may transform the texture to
  643.   control the density of the marble veins.
  644.   .TP
  645.   \fBwood\fR
  646. --- 742,756 ----
  647.   output of fBm function.  Any value lower than \fIthresh\fR is set to zero.
  648.   .TP
  649.   \fBfbmbump \fIscale offset H lambda octaves thresh\fR
  650. ! This texture is similar to the \fBfbm\fR texture.  Rather modifying the
  651. ! color of a surface, \fBfbmbump\fR acts as a bump map.
  652.   .TP
  653.   \fBmarble\fR [\fIcolormap\fR]
  654.   This texture gives a surface a marble-like appearance.  If the name of a
  655.   \fIcolormap\fR file is given, the marble will be colored using the RGB values
  656. ! in the colormap.  If no colormap name is given, the diffuse and ambient
  657. ! components of
  658. ! the object's surface are simply scaled.  One may transform the texture to
  659.   control the density of the marble veins.
  660.   .TP
  661.   \fBwood\fR
  662. ***************
  663. *** 712,721 ****
  664.   256 lines in length, each line containing three space-separated integers
  665.   ranging from 0 to 255.  The first number on the nth line specifies the red
  666.   component of the nth entry in the colormap, the second number the green 
  667. ! component, and the third the blue.
  668.   .PP
  669.   It is important to note that more than one texture may be applied to
  670. ! a point at any time.  In addition to being able to apply more than
  671.   one texture directly (by supplying multiple "texturing information" lines for
  672.   a single object), one may instantiate textured objects which, in turn,
  673.   may be textured or contain instances of objects which are textured, and so on.
  674. --- 761,774 ----
  675.   256 lines in length, each line containing three space-separated integers
  676.   ranging from 0 to 255.  The first number on the nth line specifies the red
  677.   component of the nth entry in the colormap, the second number the green 
  678. ! component, and the third the blue.  The values in the colormap are normalized
  679. ! before being used in texturing functions.
  680. ! Textures which make use of colormaps
  681. ! generally compute an index into the colormap and use the corresponding
  682. ! entry to scale the ambient and diffuse components of a surface's color.
  683.   .PP
  684.   It is important to note that more than one texture may be applied to
  685. ! an object at any time.  In addition to being able to apply more than
  686.   one texture directly (by supplying multiple "texturing information" lines for
  687.   a single object), one may instantiate textured objects which, in turn,
  688.   may be textured or contain instances of objects which are textured, and so on.
  689. ***************
  690. *** 724,738 ****
  691.   .PP
  692.   .I Rayshade
  693.   has the capability of including several kinds of atmospheric effects
  694. ! when rendering an image.  Currently, one such effect is available:
  695.   .TP
  696.   \fBfog\fI thinness red green blue\fR
  697.   Add global exponential fog with the specified \fIthinness\fR and color.
  698.   Fog is simulated by blending the color of the fog with the color of
  699. ! each ray.  The amount of fog color added to a ray is a function of
  700. ! the logarithm of the
  701. ! distance from the ray origin to the point of intersection divided by
  702. ! \fIthinness\fR.
  703.   .br
  704.   .SH "SAMPLING"
  705.   .PP
  706. --- 777,803 ----
  707.   .PP
  708.   .I Rayshade
  709.   has the capability of including several kinds of atmospheric effects
  710. ! when rendering an image.  Currently, two such effects are available:
  711.   .TP
  712.   \fBfog\fI thinness red green blue\fR
  713.   Add global exponential fog with the specified \fIthinness\fR and color.
  714.   Fog is simulated by blending the color of the fog with the color of
  715. ! each ray.  The amount of fog color blended into a ray color is an exponential
  716. ! function of the distance from the ray origin to the point of intersection
  717. ! divided by \fIthinness\fR.  If the distance divided by \fIthinness\fR
  718. ! is equal to 1, a ray's new color will be half of the fog color plus half its
  719. ! original color.
  720. ! .TP
  721. ! \fBmist\fI red green blue trans.red trans.green trans.blue zero scale\fR
  722. ! Add global low-altitude mist of the specified color.  The color of
  723. ! a ray is modulated by a fog with density which varies linearly with
  724. ! the difference in altitude (Z coordinate) between the ray origin and
  725. ! the point of intersection.  The three
  726. ! trans values specify the transmissivity (thinness) of the mist for
  727. ! each of the red, green and blue channels.  The base altitude of the
  728. ! mist is given by \fIzero\fR, and the apparent height of the mist can
  729. ! be controlled by \fIscale\fR, which is used to scale the difference in
  730. ! altitude.
  731.   .br
  732.   .SH "SAMPLING"
  733.   .PP
  734. ***************
  735. *** 748,754 ****
  736.   the \fBcontrast\fR command.
  737.   There are separate
  738.   thresholds for the red, green, and blue channels.  If the contrast
  739. ! in any of the three is greater than the appropriate treshold value,
  740.   the pixel is subdivided.
  741.   The pixel-subdivision process is repeated until either
  742.   the samples' contrast is less than the threshold or the maximum pixel
  743. --- 813,819 ----
  744.   the \fBcontrast\fR command.
  745.   There are separate
  746.   thresholds for the red, green, and blue channels.  If the contrast
  747. ! in any of the three is greater than the appropriate threshold value,
  748.   the pixel is subdivided.
  749.   The pixel-subdivision process is repeated until either
  750.   the samples' contrast is less than the threshold or the maximum pixel
  751. ***************
  752. *** 764,770 ****
  753.   \fB-S\fR option.  The integer following this option specifies the square
  754.   root of the number of regions.
  755.   .PP
  756. ! Each area light source is, in effect, approximated by a square grid
  757.   of light
  758.   sources.  The length of each side of the square is equal to the diameter
  759.   of the extended source.
  760. --- 829,835 ----
  761.   \fB-S\fR option.  The integer following this option specifies the square
  762.   root of the number of regions.
  763.   .PP
  764. ! Each extended light source is, in effect, approximated by a square grid
  765.   of light
  766.   sources.  The length of each side of the square is equal to the diameter
  767.   of the extended source.
  768. ***************
  769. *** 830,836 ****
  770.   .IN -8
  771.   .fi
  772.   .PP
  773. ! Passing this file to
  774.   .I rayshade
  775.   will result in an image of a red reflective sphere sitting on a white
  776.   ground-plane being written to the standard output.  Note that in this case,
  777. --- 895,901 ----
  778.   .IN -8
  779.   .fi
  780.   .PP
  781. ! Passing this input to
  782.   .I rayshade
  783.   will result in an image of a red reflective sphere sitting on a white
  784.   ground-plane being written to the standard output.  Note that in this case,
  785. ***************
  786. *** 908,914 ****
  787.   .fi
  788.   could be used to define a very primitive truck-like object.
  789.   .br
  790. ! .SH "MINIMIZING RAYTRACING TIME"
  791.   .PP
  792.   Ray tracing is a computationally intensive process, and rendering
  793.   complex scenes can take hours of CPU time, even on relatively powerful
  794. --- 973,979 ----
  795.   .fi
  796.   could be used to define a very primitive truck-like object.
  797.   .br
  798. ! .SH "RENDERING HINTS"
  799.   .PP
  800.   Ray tracing is a computationally intensive process, and rendering
  801.   complex scenes can take hours of CPU time, even on relatively powerful
  802. ***************
  803. *** 920,926 ****
  804.   of the image to be rendered.  The
  805.   .B \-P
  806.   option may be used to reduce the maximum pixel subdivision level.
  807. ! A maximum level of 0 will speed raytracing up considerably, but will result
  808.   in obvious aliasing in the image.  By default, a pixel will be subdivided
  809.   a maximum of one time, giving a maximum of nine rays per pixel total.
  810.   .PP 
  811. --- 985,991 ----
  812.   of the image to be rendered.  The
  813.   .B \-P
  814.   option may be used to reduce the maximum pixel subdivision level.
  815. ! A maximum level of 0 will speed ray tracing considerably, but will result
  816.   in obvious aliasing in the image.  By default, a pixel will be subdivided
  817.   a maximum of one time, giving a maximum of nine rays per pixel total.
  818.   .PP 
  819. ***************
  820. *** 941,949 ****
  821.   .B maxdepth
  822.   to a small number.  If set to 0, no reflection or
  823.   refraction rays will be traced. 
  824. ! Lastly, removing all light sources
  825. ! will cause no shadow rays to be traced, but will result in a flat-looking
  826. ! image.
  827.   .PP
  828.   In addition, judicious use of the \fBgrid\fR command can reduce rendering
  829.   times substantially.
  830. --- 1006,1012 ----
  831.   .B maxdepth
  832.   to a small number.  If set to 0, no reflection or
  833.   refraction rays will be traced. 
  834. ! Lastly, using the \fB-n\fR option will cause no shadow rays to be traced.
  835.   .PP
  836.   In addition, judicious use of the \fBgrid\fR command can reduce rendering
  837.   times substantially.
  838. ***************
  839. *** 950,955 ****
  840. --- 1013,1024 ----
  841.   However, if an object consists of a relatively small number of simple objects,
  842.   it will likely take less time to simply check for intersection with
  843.   each element of the object than to trace a ray through a grid.
  844. + .PP
  845. + The C pre-processor can be used to make the creation and managing of input
  846. + files much easier.  For example, one can create "libraries" of useful colors,
  847. + objects, and viewing parameters by using #define and #include.  To use such
  848. + input files, run the C pre-processor on the file, and pipe the resulting
  849. + text to rayshade.
  850.   .br
  851.   .SH FILES
  852.   .nf
  853. ***************
  854. *** 960,966 ****
  855.   .I Rayshade
  856.   had its beginnings as an
  857.   "introductory" public-domain
  858. ! raytracer written by Roman Kuchkuda.  Vestiges of his code may be found
  859.   in rayshade, particularly in the names of variables and the superquadric
  860.   code.
  861.   The first version of
  862. --- 1029,1035 ----
  863.   .I Rayshade
  864.   had its beginnings as an
  865.   "introductory" public-domain
  866. ! ray tracer written by Roman Kuchkuda.  Vestiges of his code may be found
  867.   in rayshade, particularly in the names of variables and the superquadric
  868.   code.
  869.   The first version of
  870. ***************
  871. *** 972,978 ****
  872.   was written during the fall of 1988 by Craig Kolb.
  873.   The Noise() and DNoise() routines which form the basis of many
  874.   of the texturing functions were written by Robert Skinner and Ken
  875. ! Musgrave.
  876.   .br
  877.   .SH "CAVEATS"
  878.   .PP
  879. --- 1041,1047 ----
  880.   was written during the fall of 1988 by Craig Kolb.
  881.   The Noise() and DNoise() routines which form the basis of many
  882.   of the texturing functions were written by Robert Skinner and Ken
  883. ! Musgrave.  The depth of field code appears courtesy of Rodney G. Bogart.
  884.   .br
  885.   .SH "CAVEATS"
  886.   .PP
  887. ***************
  888. *** 994,1000 ****
  889.   The "Total memory allocated" statistic is the total space allocated by
  890.   calls to malloc.  It is \fInot\fR the memory high-water mark.  After
  891.   the input file is processed, memory is only allocated when refraction
  892. ! occurs (to push media onto a stack) and when raytracing height fields
  893.   (to dynamically allocate triangles).
  894.   .PP
  895.   The image produced will always be 24 bits deep.
  896. --- 1063,1069 ----
  897.   The "Total memory allocated" statistic is the total space allocated by
  898.   calls to malloc.  It is \fInot\fR the memory high-water mark.  After
  899.   the input file is processed, memory is only allocated when refraction
  900. ! occurs (to push media onto a stack) and when ray tracing height fields
  901.   (to dynamically allocate triangles).
  902.   .PP
  903.   The image produced will always be 24 bits deep.
  904.  
  905. Index: src/raytrace.c
  906. *** src/raytrace.c.old    Thu Dec  7 23:21:04 1989
  907. --- src/raytrace.c    Thu Dec  7 23:21:06 1989
  908. ***************
  909. *** 18,26 ****
  910.    * name of the person performing the modification, the date of modification,
  911.    * and the reason for such modification.
  912.    *
  913. !  * $Id: raytrace.c,v 3.0.1.2 89/11/16 20:35:30 craig Exp Locker: craig $
  914.    *
  915.    * $Log:    raytrace.c,v $
  916.    * Revision 3.0.1.2  89/11/16  20:35:30  craig
  917.    * patch1: ShadeRay is now called on background rays.
  918.    * 
  919. --- 18,35 ----
  920.    * name of the person performing the modification, the date of modification,
  921.    * and the reason for such modification.
  922.    *
  923. !  * $Id: raytrace.c,v 3.0.1.5 89/12/07 22:55:25 craig Exp $
  924.    *
  925.    * $Log:    raytrace.c,v $
  926. +  * Revision 3.0.1.5  89/12/07  22:55:25  craig
  927. +  * patch2: Renamed utime and stime to avoid name clashes.
  928. +  * 
  929. +  * Revision 3.0.1.4  89/12/02  16:41:46  craig
  930. +  * patch2: Added ReportFreq, reporting of total CPU & split times.
  931. +  * 
  932. +  * Revision 3.0.1.3  89/12/02  14:42:37  craig
  933. +  * patch2: Added call to focus_blur_ray() to support depth of field.
  934. +  * 
  935.    * Revision 3.0.1.2  89/11/16  20:35:30  craig
  936.    * patch1: ShadeRay is now called on background rays.
  937.    * 
  938. ***************
  939. *** 61,66 ****
  940. --- 70,76 ----
  941.   int    *SampleNumbers;
  942.   int    SampleNumber;
  943.   int    StartLine = UNSET;
  944. + int    ReportFreq;            /* Frequency of status report */
  945.   double    RedContrast = UNSET, GreenContrast = UNSET, BlueContrast = UNSET;
  946.   double    SampleSpacing;
  947.   
  948. ***************
  949. *** 92,98 ****
  950.   {
  951.   #ifdef LINDA
  952.       extern unsigned long primtests[], primhits[];
  953. !     extern double utime, stime;
  954.       extern unsigned long EyeRays, ShadowRays, ReflectRays, RefractRays,
  955.               CacheWorked, CacheFailed, ShadowHits, SuperSampled,
  956.               BVTests, HitRays;
  957. --- 102,108 ----
  958.   {
  959.   #ifdef LINDA
  960.       extern unsigned long primtests[], primhits[];
  961. !     extern double usertime, systime;
  962.       extern unsigned long EyeRays, ShadowRays, ReflectRays, RefractRays,
  963.               CacheWorked, CacheFailed, ShadowHits, SuperSampled,
  964.               BVTests, HitRays;
  965. ***************
  966. *** 143,150 ****
  967.               primhits[j] += hittmp[j];
  968.           }
  969.           in ("timing", ? utmp, ? stmp);
  970. !         utime += utmp / (double)Workers;
  971. !         stime += stmp / (double)Workers;
  972.           in("worker", ? int);
  973.       }
  974.   #endif
  975. --- 153,160 ----
  976.               primhits[j] += hittmp[j];
  977.           }
  978.           in ("timing", ? utmp, ? stmp);
  979. !         usertime += utmp / (double)Workers;
  980. !         systime += stmp / (double)Workers;
  981.           in("worker", ? int);
  982.       }
  983.   #endif
  984. ***************
  985. *** 160,165 ****
  986. --- 170,178 ----
  987.       extern unsigned long EyeRays;
  988.   #ifdef LINDA
  989.       extern int VerboseWorker;
  990. + #else
  991. +     double usertime, systime, lasttime;
  992. +     extern int Verbose;
  993.   #endif
  994.   
  995.       switch (JitSamples) {
  996. ***************
  997. *** 205,211 ****
  998.           in("result", y, ? out_buf:);
  999.           if (VerboseWorker)
  1000.               fprintf(stderr,"Supervisor: inned %d\n",y);
  1001. !         if (y % 10 == 0)
  1002.               fprintf(fstats, "Finished line %d.\n",y);
  1003.           fflush(fstats);
  1004.           outline(out_buf);
  1005. --- 218,224 ----
  1006.           in("result", y, ? out_buf:);
  1007.           if (VerboseWorker)
  1008.               fprintf(stderr,"Supervisor: inned %d\n",y);
  1009. !         if (y % ReportFreq == 0)
  1010.               fprintf(fstats, "Finished line %d.\n",y);
  1011.           fflush(fstats);
  1012.           outline(out_buf);
  1013. ***************
  1014. *** 214,225 ****
  1015.       /*
  1016.        * Trace each scanline, writing results to output file.
  1017.        */
  1018.       for (y = StartLine; y >= 0; y--) {
  1019.           trace_jit_line(y, out_buf);
  1020.           outline(out_buf);
  1021. !         if (y % 10 == 0) {
  1022. !             fprintf(fstats,"Finished line %d (%ld rays)\n",y,
  1023.                               EyeRays);
  1024.               fflush(fstats);
  1025.           }
  1026.       }
  1027. --- 227,251 ----
  1028.       /*
  1029.        * Trace each scanline, writing results to output file.
  1030.        */
  1031. +     lasttime = 0;
  1032.       for (y = StartLine; y >= 0; y--) {
  1033.           trace_jit_line(y, out_buf);
  1034.           outline(out_buf);
  1035. !         if (y % ReportFreq == 0) {
  1036. !             fprintf(fstats,"Finished line %d (%ld rays",y,
  1037.                               EyeRays);
  1038. +             if (Verbose) {
  1039. +                 /*
  1040. +                  * Report total CPU and split times.
  1041. +                  */
  1042. +                 get_cpu_time(&usertime, &systime);
  1043. +                 fprintf(fstats,", %2.2lf sec,",
  1044. +                         usertime+systime);
  1045. +                 fprintf(fstats," %2.2lf split",
  1046. +                         usertime+systime-lasttime);
  1047. +                 lasttime = usertime+systime;
  1048. +             }
  1049. +             fprintf(fstats,")\n");
  1050.               fflush(fstats);
  1051.           }
  1052.       }
  1053. ***************
  1054. *** 270,276 ****
  1055.       extern unsigned long EyeRays;
  1056.       extern FILE *fstats;
  1057.   #ifdef LINDA
  1058. !     extern int maxlevel, VerboseWorker;
  1059.   #endif
  1060.   
  1061.       /*
  1062. --- 296,305 ----
  1063.       extern unsigned long EyeRays;
  1064.       extern FILE *fstats;
  1065.   #ifdef LINDA
  1066. !     extern int VerboseWorker;
  1067. ! #else
  1068. !     double usertime, systime, lasttime;
  1069. !     extern int Verbose;
  1070.   #endif
  1071.   
  1072.       /*
  1073. ***************
  1074. *** 338,346 ****
  1075.           while (inp("result", line, ? out_buf:)) {
  1076.               if (VerboseWorker)
  1077.                   fprintf(stderr,"Supervisor: inned %d\n",line);
  1078. !             if (line % 10 == 0)
  1079.                   fprintf(fstats, "Finished line %d.\n",line);
  1080. !             fflush(fstats);
  1081.               outline(out_buf);
  1082.               if (--line < 0)
  1083.                   break;
  1084. --- 367,376 ----
  1085.           while (inp("result", line, ? out_buf:)) {
  1086.               if (VerboseWorker)
  1087.                   fprintf(stderr,"Supervisor: inned %d\n",line);
  1088. !             if (line % ReportFreq == 0) {
  1089.                   fprintf(fstats, "Finished line %d.\n",line);
  1090. !                 fflush(fstats);
  1091. !             }
  1092.               outline(out_buf);
  1093.               if (--line < 0)
  1094.                   break;
  1095. ***************
  1096. *** 349,354 ****
  1097. --- 379,385 ----
  1098.   #else
  1099.       line = StartLine + 1;
  1100.       trace_line(line, &pixel_buf[line & 01][0]);
  1101. +     lasttime = 0;
  1102.       /*
  1103.        * Work bottom-to-top, as that's the way Utah-raster wants to
  1104.        * operate.
  1105. ***************
  1106. *** 359,367 ****
  1107.                        pixel_buf[(line+1) & 01],
  1108.                        out_buf);
  1109.           outline(out_buf);
  1110. !         if(line % 10 == 0) {
  1111. !             fprintf(fstats,"Finished line %d (%ld rays)\n",line,
  1112.                                   EyeRays);
  1113.               fflush(fstats);
  1114.           }
  1115.       }
  1116. --- 390,410 ----
  1117.                        pixel_buf[(line+1) & 01],
  1118.                        out_buf);
  1119.           outline(out_buf);
  1120. !         if(line % ReportFreq == 0) {
  1121. !             fprintf(fstats,"Finished line %d (%ld rays",line,
  1122.                                   EyeRays);
  1123. +             if (Verbose) {
  1124. +                 /*
  1125. +                  * Report total CPU and split times.
  1126. +                  */
  1127. +                 get_cpu_time(&usertime, &systime);
  1128. +                 fprintf(fstats,", %2.2lf sec,",
  1129. +                         usertime+systime);
  1130. +                 fprintf(fstats," %2.2lf split",
  1131. +                         usertime+systime-lasttime);
  1132. +                 lasttime = usertime+systime;
  1133. +             }
  1134. +             fprintf(fstats,")\n");
  1135.               fflush(fstats);
  1136.           }
  1137.       }
  1138. ***************
  1139. *** 499,504 ****
  1140. --- 542,548 ----
  1141.       double dist;
  1142.       HitInfo hitinfo;
  1143.       extern Vector scrnx, scrny;
  1144. +     extern double aperture;
  1145.       extern unsigned long EyeRays;
  1146.       extern double TraceRay();
  1147.   
  1148. ***************
  1149. *** 511,516 ****
  1150. --- 555,568 ----
  1151.       TopRay.dir.z = firstray.z + x*scrnx.z - y*scrny.z;
  1152.   
  1153.       (void)normalize(&TopRay.dir);
  1154. +     if (aperture > 0.0) {
  1155. +         /*
  1156. +          * If the aperture is open, adjust the initial ray
  1157. +          * to account for depth of field.  
  1158. +          */
  1159. +         focus_blur_ray(&TopRay);
  1160. +     }
  1161.   
  1162.       /*
  1163.        * Do the actual ray trace.
  1164.  
  1165. Index: src/setup.c
  1166. *** src/setup.c.old    Thu Dec  7 23:21:12 1989
  1167. --- src/setup.c    Thu Dec  7 23:21:13 1989
  1168. ***************
  1169. *** 18,26 ****
  1170.    * name of the person performing the modification, the date of modification,
  1171.    * and the reason for such modification.
  1172.    *
  1173. !  * $Id: setup.c,v 3.0 89/10/27 02:06:03 craig Exp $
  1174.    *
  1175.    * $Log:    setup.c,v $
  1176.    * Revision 3.0  89/10/27  02:06:03  craig
  1177.    * Baseline for first official release.
  1178.    * 
  1179. --- 18,29 ----
  1180.    * name of the person performing the modification, the date of modification,
  1181.    * and the reason for such modification.
  1182.    *
  1183. !  * $Id: setup.c,v 3.0.1.1 89/12/02 16:52:33 craig Exp $
  1184.    *
  1185.    * $Log:    setup.c,v $
  1186. +  * Revision 3.0.1.1  89/12/02  16:52:33  craig
  1187. +  * patch2: Added code to set default value for ReportFreq.
  1188. +  * 
  1189.    * Revision 3.0  89/10/27  02:06:03  craig
  1190.    * Baseline for first official release.
  1191.    * 
  1192. ***************
  1193. *** 40,46 ****
  1194.    */
  1195.   setup()
  1196.   {
  1197. !     extern int maxlevel;
  1198.       extern double hfov, vfov;
  1199.       extern Vector eyep, lookp, up;
  1200.       extern Object *World;
  1201. --- 43,49 ----
  1202.    */
  1203.   setup()
  1204.   {
  1205. !     extern int maxlevel, ReportFreq;
  1206.       extern double hfov, vfov;
  1207.       extern Vector eyep, lookp, up;
  1208.       extern Object *World;
  1209. ***************
  1210. *** 80,85 ****
  1211. --- 83,89 ----
  1212.       up.x = UPX;
  1213.       up.y = UPY;
  1214.       up.z = UPZ;
  1215. +     ReportFreq = REPORTFREQ;
  1216.   
  1217.       /*
  1218.        * Kinda yicky, but compatible.
  1219.  
  1220. Index: src/sphere.c
  1221. *** src/sphere.c.old    Thu Dec  7 23:21:19 1989
  1222. --- src/sphere.c    Thu Dec  7 23:21:20 1989
  1223. ***************
  1224. *** 18,26 ****
  1225.    * name of the person performing the modification, the date of modification,
  1226.    * and the reason for such modification.
  1227.    *
  1228. !  * $Id: sphere.c,v 3.0 89/10/27 02:06:04 craig Exp $
  1229.    *
  1230.    * $Log:    sphere.c,v $
  1231.    * Revision 3.0  89/10/27  02:06:04  craig
  1232.    * Baseline for first official release.
  1233.    * 
  1234. --- 18,29 ----
  1235.    * name of the person performing the modification, the date of modification,
  1236.    * and the reason for such modification.
  1237.    *
  1238. !  * $Id: sphere.c,v 3.0.1.1 89/12/06 16:33:35 craig Exp $
  1239.    *
  1240.    * $Log:    sphere.c,v $
  1241. +  * Revision 3.0.1.1  89/12/06  16:33:35  craig
  1242. +  * patch2: Added calls to new error/warning routines.
  1243. +  * 
  1244.    * Revision 3.0  89/10/27  02:06:04  craig
  1245.    * Baseline for first official release.
  1246.    * 
  1247. ***************
  1248. *** 43,54 ****
  1249.       Sphere       *sphere;
  1250.       Object *newobj;
  1251.       Primitive *prim;
  1252. -     extern int Quiet, yylineno;
  1253.   
  1254.       if (r < EPSILON) {
  1255. !         if (!Quiet)
  1256. !             fprintf(stderr,"Degenerate sphere (line %d)\n",
  1257. !                             yylineno);
  1258.           return (Object *)0;
  1259.       }
  1260.   
  1261. --- 46,54 ----
  1262.       Sphere       *sphere;
  1263.       Object *newobj;
  1264.       Primitive *prim;
  1265.   
  1266.       if (r < EPSILON) {
  1267. !         yywarning("Degenerate sphere.\n");
  1268.           return (Object *)0;
  1269.       }
  1270.   
  1271.  
  1272. Index: src/surface.c
  1273. *** src/surface.c.old    Thu Dec  7 23:21:25 1989
  1274. --- src/surface.c    Thu Dec  7 23:21:26 1989
  1275. ***************
  1276. *** 18,26 ****
  1277.    * name of the person performing the modification, the date of modification,
  1278.    * and the reason for such modification.
  1279.    *
  1280. !  * $Id: surface.c,v 3.0 89/10/27 02:06:05 craig Exp $
  1281.    *
  1282.    * $Log:    surface.c,v $
  1283.    * Revision 3.0  89/10/27  02:06:05  craig
  1284.    * Baseline for first official release.
  1285.    * 
  1286. --- 18,29 ----
  1287.    * name of the person performing the modification, the date of modification,
  1288.    * and the reason for such modification.
  1289.    *
  1290. !  * $Id: surface.c,v 3.0.1.1 89/12/06 16:33:11 craig Exp $
  1291.    *
  1292.    * $Log:    surface.c,v $
  1293. +  * Revision 3.0.1.1  89/12/06  16:33:11  craig
  1294. +  * patch2: Added calls to new error/warning routines.
  1295. +  * 
  1296.    * Revision 3.0  89/10/27  02:06:05  craig
  1297.    * Baseline for first official release.
  1298.    * 
  1299. ***************
  1300. *** 50,56 ****
  1301.        * Complain if named surface already exists.
  1302.        */
  1303.       if ((stmp = get_surface(name)) != (Surface *)0)
  1304. !         yyerror("Surface redefined.");
  1305.   
  1306.       stmp = (Surface *)Malloc(sizeof(Surface));
  1307.       stmp->name = strsave(name);
  1308. --- 53,59 ----
  1309.        * Complain if named surface already exists.
  1310.        */
  1311.       if ((stmp = get_surface(name)) != (Surface *)0)
  1312. !         yyerror("Surface \"%s\" redefined.", name);
  1313.   
  1314.       stmp = (Surface *)Malloc(sizeof(Surface));
  1315.       stmp->name = strsave(name);
  1316. ***************
  1317. *** 91,97 ****
  1318.   
  1319.       stmp = get_surface(name);
  1320.       if (stmp == (Surface *)0)
  1321. !         yyerror("Undefined surface.");
  1322.   
  1323.       return stmp;
  1324.   }
  1325. --- 94,100 ----
  1326.   
  1327.       stmp = get_surface(name);
  1328.       if (stmp == (Surface *)0)
  1329. !         yyerror("Undefined surface \"%s\".", name);
  1330.   
  1331.       return stmp;
  1332.   }
  1333.  
  1334. Index: src/texture.c
  1335. *** src/texture.c.old    Thu Dec  7 23:21:40 1989
  1336. --- src/texture.c    Thu Dec  7 23:21:41 1989
  1337. ***************
  1338. *** 18,26 ****
  1339.    * name of the person performing the modification, the date of modification,
  1340.    * and the reason for such modification.
  1341.    *
  1342. !  * $Id: texture.c,v 3.0 89/10/27 02:06:05 craig Exp $
  1343.    *
  1344.    * $Log:    texture.c,v $
  1345.    * Revision 3.0  89/10/27  02:06:05  craig
  1346.    * Baseline for first official release.
  1347.    * 
  1348. --- 18,33 ----
  1349.    * name of the person performing the modification, the date of modification,
  1350.    * and the reason for such modification.
  1351.    *
  1352. !  * $Id: texture.c,v 3.0.1.2 89/12/06 16:33:50 craig Exp $
  1353.    *
  1354.    * $Log:    texture.c,v $
  1355. +  * Revision 3.0.1.2  89/12/06  16:33:50  craig
  1356. +  * patch2: Added calls to new error/warning routines.
  1357. +  * 
  1358. +  * Revision 3.0.1.1  89/11/27  18:36:54  craig
  1359. +  * patch2: Removed hardcoded constants in calculation of ambient
  1360. +  * patch2: component in several textures.
  1361. +  * 
  1362.    * Revision 3.0  89/10/27  02:06:05  craig
  1363.    * Baseline for first official release.
  1364.    * 
  1365. ***************
  1366. *** 132,139 ****
  1367.       surf->diff.r *= red;
  1368.       surf->diff.g *= grn;
  1369.       surf->diff.b *= blu;
  1370. !     ScaleColor(0.3, surf->diff, &surf->amb);
  1371.   }
  1372.   
  1373.   /*
  1374. --- 139,147 ----
  1375.       surf->diff.r *= red;
  1376.       surf->diff.g *= grn;
  1377.       surf->diff.b *= blu;
  1378. !     surf->amb.r *= red;
  1379. !     surf->amb.g *= grn;
  1380. !     surf->amb.b *= blu;
  1381.   }
  1382.   
  1383.   /*
  1384. ***************
  1385. *** 271,278 ****
  1386.           index = 255. * val;
  1387.           if (index > 255) index = 255;
  1388.           if (index < 0) index = 0;
  1389. !         surf->diff = text->colormap[index];
  1390. !         ScaleColor(.2, surf->diff, &surf->amb);
  1391.       } else {
  1392.           ScaleColor(val, surf->diff, &surf->diff);
  1393.           ScaleColor(val, surf->amb, &surf->amb);
  1394. --- 279,290 ----
  1395.           index = 255. * val;
  1396.           if (index > 255) index = 255;
  1397.           if (index < 0) index = 0;
  1398. !         surf->diff.r *= text->colormap[index].r;
  1399. !         surf->diff.g *= text->colormap[index].g;
  1400. !         surf->diff.b *= text->colormap[index].b;
  1401. !         surf->amb.r *= text->colormap[index].r;
  1402. !         surf->amb.g *= text->colormap[index].g;
  1403. !         surf->amb.b *= text->colormap[index].b;
  1404.       } else {
  1405.           ScaleColor(val, surf->diff, &surf->diff);
  1406.           ScaleColor(val, surf->amb, &surf->amb);
  1407. ***************
  1408. *** 341,347 ****
  1409.       val = Marble(pos);
  1410.       if (text->colormap) {
  1411.           index = (int)(255. * val);
  1412. !         surf->diff = text->colormap[index];
  1413.       } else {
  1414.           ScaleColor(val, surf->amb, &surf->amb);
  1415.           ScaleColor(val, surf->diff, &surf->diff);
  1416. --- 353,364 ----
  1417.       val = Marble(pos);
  1418.       if (text->colormap) {
  1419.           index = (int)(255. * val);
  1420. !         surf->diff.r *= text->colormap[index].r;
  1421. !         surf->diff.g *= text->colormap[index].g;
  1422. !         surf->diff.b *= text->colormap[index].b;
  1423. !         surf->amb.r *= text->colormap[index].r;
  1424. !         surf->amb.g *= text->colormap[index].g;
  1425. !         surf->amb.b *= text->colormap[index].b;
  1426.       } else {
  1427.           ScaleColor(val, surf->amb, &surf->amb);
  1428.           ScaleColor(val, surf->diff, &surf->diff);
  1429. ***************
  1430. *** 359,365 ****
  1431.   
  1432.       fp = fopen(filename, "r");
  1433.       if (fp == (FILE *)NULL)
  1434. !         yyerror("Cannot open colormap file.");
  1435.   
  1436.       map = (Color *)Calloc(256, sizeof(Color));
  1437.   
  1438. --- 376,382 ----
  1439.   
  1440.       fp = fopen(filename, "r");
  1441.       if (fp == (FILE *)NULL)
  1442. !         yyerror("Cannot open colormap file \"%s\".\n", filename);
  1443.   
  1444.       map = (Color *)Calloc(256, sizeof(Color));
  1445.   
  1446.  
  1447. Index: src/viewing.c
  1448. *** src/viewing.c.old    Thu Dec  7 23:21:53 1989
  1449. --- src/viewing.c    Thu Dec  7 23:21:54 1989
  1450. ***************
  1451. *** 18,26 ****
  1452.    * name of the person performing the modification, the date of modification,
  1453.    * and the reason for such modification.
  1454.    *
  1455. !  * $Id: viewing.c,v 3.0.1.1 89/11/16 18:24:30 craig Exp Locker: craig $
  1456.    *
  1457.    * $Log:    viewing.c,v $
  1458.    * Revision 3.0.1.1  89/11/16  18:24:30  craig
  1459.    * patch1: Fixed calculation of dist in Stereo mode.
  1460.    * 
  1461. --- 18,33 ----
  1462.    * name of the person performing the modification, the date of modification,
  1463.    * and the reason for such modification.
  1464.    *
  1465. !  * $Id: viewing.c,v 3.0.1.3 89/12/02 14:38:37 craig Exp $
  1466.    *
  1467.    * $Log:    viewing.c,v $
  1468. +  * Revision 3.0.1.3  89/12/02  14:38:37  craig
  1469. +  * patch2: Added depth of field code, courtesy of Rodney G. Bogart.
  1470. +  * 
  1471. +  * Revision 3.0.1.2  89/11/27  19:07:49  craig
  1472. +  * patch2: Changed calculation of scrny when NORLE is defined so images
  1473. +  * patch2: will be rendered top-to-bottom.
  1474. +  * 
  1475.    * Revision 3.0.1.1  89/11/16  18:24:30  craig
  1476.    * patch1: Fixed calculation of dist in Stereo mode.
  1477.    * 
  1478. ***************
  1479. *** 34,54 ****
  1480.   #include "typedefs.h"
  1481.   #include "funcdefs.h"
  1482.   
  1483.   Vector lookp, eyep, up, firstray, scrnx, scrny;
  1484.   double vfov, hfov, Separation;
  1485.   int Xres = UNSET, Yres = UNSET, Stereo;
  1486.   viewing()
  1487.   {
  1488.       Vector gaze;
  1489. !     double dist, magnitude;
  1490.   
  1491.       vecsub(lookp, eyep, &gaze);
  1492.       firstray = gaze;
  1493.   
  1494.       dist = normalize(&gaze);
  1495. !     (void)crossp(&scrnx, &gaze, &up);
  1496. !     (void)crossp(&scrny, &scrnx, &gaze);
  1497. !     dist *= 2.0;
  1498.   
  1499.       /*
  1500.        * Add stereo separation if desired.
  1501. --- 41,63 ----
  1502.   #include "typedefs.h"
  1503.   #include "funcdefs.h"
  1504.   
  1505. + Vector scrni, scrnj;        /* Unit vectors of screen plane. */
  1506.   Vector lookp, eyep, up, firstray, scrnx, scrny;
  1507.   double vfov, hfov, Separation;
  1508. + double aperture = 0., focaldist = UNSET;
  1509.   int Xres = UNSET, Yres = UNSET, Stereo;
  1510.   viewing()
  1511.   {
  1512.       Vector gaze;
  1513. !     double magnitude, dist;
  1514.   
  1515.       vecsub(lookp, eyep, &gaze);
  1516.       firstray = gaze;
  1517.   
  1518.       dist = normalize(&gaze);
  1519. !     (void)crossp(&scrni, &gaze, &up);
  1520. !     (void)crossp(&scrnj, &scrni, &gaze);
  1521.   
  1522.       /*
  1523.        * Add stereo separation if desired.
  1524. ***************
  1525. *** 58,83 ****
  1526.               magnitude = -.5 * Separation;
  1527.           else
  1528.               magnitude = .5 * Separation;
  1529. !         eyep.x += magnitude * scrnx.x;
  1530. !         eyep.y += magnitude * scrnx.y;
  1531. !         eyep.z += magnitude * scrnx.z;
  1532.           vecsub(lookp, eyep, &firstray);
  1533.           gaze = firstray;
  1534. !         dist = 2. * normalize(&gaze);
  1535. !         (void)crossp(&scrnx, &gaze, &up);
  1536. !         (void)crossp(&scrny, &scrnx, &gaze);
  1537.       }
  1538.   
  1539. !     magnitude = dist * tan(deg2rad(0.5*hfov)) / Xres;
  1540. !     scrnx.x *= magnitude;
  1541. !     scrnx.y *= magnitude;
  1542. !     scrnx.z *= magnitude;
  1543. !     magnitude = dist * tan(deg2rad(0.5*vfov)) / Yres;
  1544. !     scrny.x *= magnitude;
  1545. !     scrny.y *= magnitude;
  1546. !     scrny.z *= magnitude;
  1547.   
  1548.       firstray.x += 0.5*Yres*scrny.x - 0.5*Xres*scrnx.x;
  1549.       firstray.y += 0.5*Yres*scrny.y - 0.5*Xres*scrnx.y;
  1550.       firstray.z += 0.5*Yres*scrny.z - 0.5*Xres*scrnx.z;
  1551.   }
  1552. --- 67,162 ----
  1553.               magnitude = -.5 * Separation;
  1554.           else
  1555.               magnitude = .5 * Separation;
  1556. !         eyep.x += magnitude * scrni.x;
  1557. !         eyep.y += magnitude * scrni.y;
  1558. !         eyep.z += magnitude * scrni.z;
  1559.           vecsub(lookp, eyep, &firstray);
  1560.           gaze = firstray;
  1561. !         dist = normalize(&gaze);
  1562. !         (void)crossp(&scrni, &gaze, &up);
  1563. !         (void)crossp(&scrnj, &scrni, &gaze);
  1564.       }
  1565.   
  1566. !     magnitude = 2. * dist * tan(deg2rad(0.5*hfov)) / Xres;
  1567. !     scrnx.x = scrni.x * magnitude;
  1568. !     scrnx.y = scrni.y * magnitude;
  1569. !     scrnx.z = scrni.z * magnitude;
  1570. !     magnitude = 2. * dist * tan(deg2rad(0.5*vfov)) / Yres;
  1571. ! #ifdef NORLE
  1572. !     magnitude *= -1;
  1573. ! #endif
  1574. !     scrny.x = scrnj.x * magnitude;
  1575. !     scrny.y = scrnj.y * magnitude;
  1576. !     scrny.z = scrnj.z * magnitude;
  1577.   
  1578.       firstray.x += 0.5*Yres*scrny.x - 0.5*Xres*scrnx.x;
  1579.       firstray.y += 0.5*Yres*scrny.y - 0.5*Xres*scrnx.y;
  1580.       firstray.z += 0.5*Yres*scrny.z - 0.5*Xres*scrnx.z;
  1581. +     if (focaldist == UNSET)
  1582. +         focaldist = dist;
  1583. + }
  1584. + /*
  1585. +  * Depth of field code courtesy of Rodney G. Bogart.
  1586. +  *
  1587. +  * Adjust the initial ray to account for an aperture and a focal
  1588. +  * distance.  The ray argument is assumed to be an initial ray, and
  1589. +  * always reset to the eye point.  It is assumed to be unit length.
  1590. +  */
  1591. + focus_blur_ray(ray)
  1592. + Ray *ray;
  1593. + {
  1594. +     Vector circle_point, aperture_inc;
  1595. +     /*
  1596. +      * Find a point on a unit circle and scale by aperture size.
  1597. +      * This simulates rays passing thru different parts of the aperture.
  1598. +      * Treat the point as a vector and rotate it so the circle lies
  1599. +      * in the plane of the screen.  Add the aperture increment to the
  1600. +      * starting position of the ray.  Stretch the ray to be focaldist 
  1601. +      * in length.  Subtract the aperture increment from the end of the
  1602. +      * long ray.  This insures that the ray heads toward a point at
  1603. +      * the specified focus distance, so that point will be in focus.
  1604. +      * Normalize the ray, and that's it.  Really.
  1605. +      */
  1606. +     unit_circle_point(&circle_point);
  1607. +     veccomb(aperture * circle_point.x, scrni,
  1608. +             aperture * circle_point.y, scrnj,
  1609. +             &aperture_inc);
  1610. +     vecadd(aperture_inc, eyep, &(ray->pos));
  1611. +     scalar_prod(focaldist, ray->dir, &(ray->dir));
  1612. +     vecsub(ray->dir, aperture_inc, &(ray->dir));
  1613. +     normalize(&ray->dir);
  1614. + }
  1615. + /*
  1616. +  * Find a point on a unit circle which is separated from other random
  1617. +  * points by some jitter spacing.
  1618. +  *
  1619. +  * It should do the above, but the temporary hack below just finds a
  1620. +  * jittered point in a unit square.
  1621. +  */
  1622. + unit_circle_point(pnt)
  1623. + Vector *pnt;
  1624. + {
  1625. +     /*
  1626. +      * This picks a random point on a -1 to 1 square.  The jitter stuff
  1627. +      * is correct enough to avoid excessive noise.  An extremely blurry
  1628. +      * bright highlight will look squarish, not roundish.  Sorry.
  1629. +      */
  1630. +     double jit;
  1631. +     extern double SampleSpacing;
  1632. +     extern int Jittered, JitSamples, SampleNumber;
  1633. +     if (Jittered) {
  1634. +         jit = 2. * SampleSpacing;
  1635. +         pnt->x = nrand()*jit - 1.0 + (SampleNumber % JitSamples) * jit;
  1636. +         pnt->y = nrand()*jit - 1.0 + (SampleNumber / JitSamples) * jit;
  1637. +         pnt->z = 0.0;
  1638. +     } else {
  1639. +         pnt->x = nrand() * 2.0 - 1.0;
  1640. +         pnt->y = nrand() * 2.0 - 1.0;
  1641. +         pnt->z = 0.0;
  1642. +     }
  1643.   }
  1644.  
  1645.  
  1646.  
  1647.