MICRORAY.TXT


Remove Frame

/************************************************************************
 *									*
 *		    Copyright (c) 1988, David B. Wecker			*
 *			    All Rights Reserved				*
 *									*
 * This file is part of DBW_uRAY					*
 *									*
 * DBW_uRAY is distributed in the hope that it will be useful, but	*
 * WITHOUT ANY WARRANTY. No author or distributor accepts		*
 * responsibility to anyone for the consequences of using it or for	*
 * whether it serves any particular purpose or works at all, unless	*
 * he says so in writing. Refer to the DBW_uRAY General Public		*
 * License for full details.						*
 *									*
 * Everyone is granted permission to copy, modify and redistribute	*
 * DBW_uRAY, but only under the conditions described in the		*
 * DBW_uRAY General Public License. A copy of this license is		*
 * supposed to have been given to you along with DBW_uRAY so you	*
 * can know your rights and responsibilities. It should be in a file	*
 * named LICENSE. Among other things, the copyright notice and this	*
 * notice must be preserved on all copies.				*
 ************************************************************************
 *									*
 * Authors:								*
 *	DBW - David B. Wecker						*
 *									*
 * Versions:								*
 *	V1.0 881023 DBW	- First released version			*
 *	V1.1 881110 DBW - Fixed scan coherence code			*
 *	V1.2 881125 DBW - Removed ALL scan coherence code (useless)	*
 *			  added "fat" extent boxes			*
 *	V1.3 881203 DBW - Fixed single precision TOLerances		*
 *									*
 ************************************************************************/

DBW_uRAY (micro raytracer) is a small raytracer developed for my own test
purposes and made available to anyone who wishes to play with ray tracing
algorithms. It runs on several different machines in many different
configurations. It has been tested on:

	Amiga 68000/68010/68020 with/without 68881 (using Manx 3.6 compiler)
	Vax   Ultrix and VMS

Its features are:

    -	VERY good ray tracing algorithm
    -	Automatic oct-tree extent generation for FAST ray tracing
    -	Simple input file format
    -	SMALL easy to read code
    -	very portable
    -	built in advanced features like waves and textures
    -	generates .ILBM files directly
    -	generates .TMP files (compatable with DBW_RENDER v2.0)
    -	easy to extend
    -	progammable aspect ratio and angle of view
    -	single or double precision floating point
    -	automatic (no overhead) sky and ground generation
    -	dithered .ILBM file for much more accurate color reproduction
    -	can generate 24 bit .TMP files ( 16 million colors )
    -	can generate pictures upto 1024 x 1024

=================
INPUT FILE FORMAT
=================

See URAY.DAT for a sample input file. The options are:

    DEPTH   - Maximum recursion depth
    COLS    - columns in the picture
    ROWS    - rows in the picture
    START   - row to start raytracing at
    END	    - row to end with
    BPP	    - Bits/Pixel in the .tmp file (24,12 or 0 (== no .tmp file wanted))
    AOV	    - angle of view (in degrees) <<<<YOUR EYE IS ALWAYS AT 0,0,0>>>>   
    ASPECT  - aspect ratio (For Amiga use .544)
    NEAR    - ambient (background color for "sky" near the eye)
    FAR	    - ambient (background color for "sky" far from the eye (horizon))
    GROUND  - ambient (background color below the horizon (y < 0))
    BASE    - minimum diffuse lighting for any object (blackness of shadows)

The background is made up of three colors:

    NEAR    - the sky overhead
    FAR	    - the sky at the horizon
    GROUND  - the ground color

Wave sources are listed with a "WAVES" statement. Parameters are:

    WAVES n	- n is the number of lines that follow. Each line has 6 numbers:
	x y z	- center of the wave
	amp	- initial amplitude of the wave
	phase	- initial phase shift
	length	- wavelength
	damp	- damping from wave to wave

Attributes are listed with an "ATTRIBUTES" statement. Parameters are:

    ATTRIBUTES n    - n is the number of lines containing:
	r g b	- base diffuse color
	Kd	- amount of diffuse coloring
	Ks	- specular factor (reflection)
	Kt	- transmission factor (transparency)
	Ir	- index of refraction (for Kt) 1.0 = none
	Kl	- self lighting factor (light source)
	dist	- inverse square law distance (0 = no inv sq law)
	Kf	- fuzz factor (0 = none 1 = max)
	Wave	- wave number (starts at 0) or -1 = no waves -2 = all waves
	tex	- texture:
	    0		    - none
	    1 r g b x y z   - checker in color (r g b) at scale (x y z)
	    2 r g b	    - random mottled (alternate color = r g b)
	    3 r g b a b c   - X axis blend (alt = r g b, X range= a - b - c)
	    4 r g b a b c   - Y axis blend (alt = r g b, Y range= a - b - c)
	    5 r g b a b c   - Z axis blend (alt = r g b, Z range= a - b - c)

Note: When refering to waves or attributes the first one defined is number 0
      the next is number 1 and so forth.

Finally objects:

    SPHERE a x y z r		- Do a sphere with attribute a (>= 0)
				  Center at (x y z) with radius r
    QUAD a x y z i j k l m n	- Do a rectangle with attribute a (>= 0)
				  Corners at (x y z), (x+i y+j z+k), and
				    (x+l y+m z+n)
    TRIANGLE a x y z i j k l m n- Do a triangle with attribute a (>= 0)
				  Corners at (x y z), (x+i y+j z+k), and
				    (x+l y+m z+n)
    RING a x y z i j k l m n b c- Do a ring with attribute a (>= 0)
				  Corners at (x y z), (x+i y+j z+k), and
				    (x+l y+m z+n) inner radius b and outer
				    radius c

===================
RUNNING THE PROGRAM
===================

If you have an input file called input.dat then just type:

	uray input

and the program will run giving output like the following:

    uRAY v1.2 881125 (C) 1988 D. Wecker - all rights reserved
    Creating objects

	Input file name:          input
	Maximum recursion depth:     20
	Dimensions:                 200 rows (0,200)  160 columns
	Bits/Pixel:                  24
	Angle of view:               60 degrees
	Aspect ratio:             0.544
	Number of attributes:         6
	Number of waves:              1

    Creating object extents
    Creating extent tree
    Using 2 extents for 2 objects


    Extent setup time:         0.17

    Row    0: ..................................................
    Row   50: ..................................................
    Row  100: ..................................................
    Row  150: .................................................


    Total  run   time:       115.40

    False hits: Extents =      60215, Nodes =       5077
    Good  hits: Extents =       6829, Nodes =       1752
    Total hits: Extents =      67044, Nodes =       6829

To display the file on the Amiga, just say:

    display input

Type a <CR> to exit the display.

=====
FILES
=====

    README	    - This file
    LICENSE	    - License agreement
    Makefile	    - rebuild control (see later section)
    Make.version    - retitle source files

    display.c	    - ILBM display program for the Amiga

    extent.c	    - automatic oct-tree extent generator
    intersect.c	    - ray intersection calculations
    output.c	    - output file generation (.ILBM and .TMP)
    random.c	    - random number generator
    rkm.c	    - RKM compression routines (for .ILBM files)
    support.c	    - file input and support routines
    texture.c	    - texture calculations
    trace.c	    - actual ray tracing code
    uray.c	    - main module
    uray.h	    - global definitions
    uray.dat	    - sample input file

    uray_ux	    - compiled Ultrix version
    uray_vm	    - compiled VMS version
    uray_sp	    - compiled Amiga single precision version
    uray_dp	    - compiled Amiga double precision version
    uray_cp	    - compiled Amiga co-processor (68881) version
    uray_2s	    - compiled Amiga 68020/single precision version
    uray_2d	    - compiled Amiga 68020/double precision version
    uray_2c	    - compiled Amiga 68020/68881 (coprocessor) version
    display	    - compiled Amiga display program

Rename the "uray_??" file that you wish to use to "uray".

========
MAKEFILE
========

For the Amiga, uncomment the appropriate definitins of FFLG, DBL and MLIB for
the type of processor/coprocessor and precision you want. Also uncomment the
"Standard flags" for the type of machine that you're on. Then:

    make uray display

will re-make the ray-tracer and the display programs. See the Makefile for
further details.