[comp.graphics] Ray Tracing & filter references

milo@ndmath.UUCP (02/01/87)

I am looking for some references on basic Ray Tracing and on image filtering
using 3x3 and larger matrices.  I am trying to find something where algorithims
are defined in computer-language terms rather than as complex mathmatical 
(ie: tons of greek letters) jargon.

Regarding the 3x3 matrix filters, I have seen the high-pass/low-pass...etc
type of matrix filtering techniques mentioned in articles about image processing
boards, unfortunately none of the articles I have describe how to calculate
the coefficients for the matrix that you need to get high-pas/low-pass and other
types of results.

As far as the Ray Tracing goes...I want some basic background information that
I might be able to use to write some simple demos along the lines of mirrored
and transparent balls and light sources with shadows.  Extreem realism is not
necessary, nor is high speed...mainly I need references that describe the
process in programmers terms.

If you could suggest any references that include code examples in C, FORTRAN
or Pascal (or any other computer language) I would appreciate it.

One other thing...I would appreciate comments from any graphics hackers on
the workability of splitting up complex Ray Tracing or other types of hidden
surface rendering algorithims between a number of CPU's for speed in processing.
I expect to have access to an ethernet with a large number (20 or more)
of identical Unix machines and I would like to experiment with breaking a
picture up in pieces and giving each machine a chunk to work on.

Greg Corson
19141 Summers Drive
South Bend, IN 46637
(219) 277-5306
...seismo!iuvax!kangaro!milo

amamaral@elrond.UUCP (02/03/87)

In article <179@ndmath.UUCP>, milo@ndmath.UUCP (Greg Corson) writes:
> I am looking for some references on basic Ray Tracing and on image filtering
> using 3x3 and larger matrices.  I am trying to find something where algorithims
> are defined in computer-language terms rather than as complex mathmatical 
> (ie: tons of greek letters) jargon.
> :
> :
> As far as the Ray Tracing goes...I want some basic background information that
> I might be able to use to write some simple demos along the lines of mirrored
> and transparent balls and light sources with shadows.
> 
> If you could suggest any references that include code examples in C, FORTRAN
> or Pascal (or any other computer language) I would appreciate it.

Try the ACM Siggraph proceedings and course notes from the last couple
of years.  The 86 "Developments In Ray Tracing" course notes include C
code from Turner Whitted for a simple ray tracer.
> 
> One other thing...I would appreciate comments from any graphics hackers on
> the workability of splitting up complex Ray Tracing or other types of hidden
> surface rendering algorithims between a number of CPU's for speed in processing.
> I expect to have access to an ethernet with a large number (20 or more)
> of identical Unix machines and I would like to experiment with breaking a
> picture up in pieces and giving each machine a chunk to work on.

Ray Tracing lends itself WONDERFULLY to this.  You can send the
identical object database to each node, and a list of scan lines to be
traced, collect the data when each node is completed, and merge the
results.  

> Greg Corson

Writing a ray tracer skeletin is extremely simple to do, it's adding the
object intersection algorighms that is relatively difficult because you
have to figure out how to intersect some surface type with a ray and
it's not trivial in anything but trivial cases (such as spheres).  Also,
getting a shading algorithm isn't real easy (at least I haven't found it
to be) because they tend to be published with lots of greek letters that
you (and I) don't seem to like...

Good luck.
-- 
uucp:	 ...decvax!elrond!amamaral		I would rather be a
phone:	 (603) 885-8075				fool than a king...
us mail: Calcomp/Sanders DPD (PTP2-2D01)
	 Hudson NH 	03051-0908

peterson@utah-gr.UUCP (02/03/87)

> One other thing...I would appreciate comments from any graphics hackers on
> the workability of splitting up complex Ray Tracing or other types of hidden
> surface rendering algorithims between a number of CPU's for speed in process!
> I expect to have access to an ethernet with a large number (20 or more)
> of identical Unix machines and I would like to experiment with breaking a
> picture up in pieces and giving each machine a chunk to work on.
>

If your making movies this is easy - just dole out frames to individual
processors.

For making a single complex still, the issue becomes much more complex.
First, you will usually lose if you just hand out equal portions to
various processors.  In most images, some complex scanlines may take 5-10
times as long as those in simpler areas of the image, particularly if
you're doing adaptive anti-aliasing.

One approach I've used is to render a small (say 128x128 pixel) copy of
the image, and keep track of the times required for each scanline.
Then use these scanline times as guide for splitting up the work on the
big picture.

Another approach - if you're really into network hacking - is to make
the ray tracer work on small chunks (say 1-10 scanlines) as a client
process.  A single server on the network then hands out chunks of the
rendering work to the ray-tracing clients until the picture is finished
(I think Apollo may make their SIGGRAPH movies this way).

If you use the first techinique, I strongly recommend generating an
alpha (matte) mask for indicating which pixels are finished.  Then all
you have to do to put pieces together is feed them to your compositor.

falk@peregrine.UUCP (02/04/87)

>						...	Also,
>getting a shading algorithm isn't real easy (at least I haven't found it
>to be) because they tend to be published with lots of greek letters that
>you (and I) don't seem to like...


Ok, here's a shading algorithm in plain english.  I implemented 2/3 of
this in microcode once, so it's pretty simple.

Disclaimer: It's only a model (shh!)

There are three kinds of light that can hit and bounce off an object:
ambient, incident and specular.  Ambient light is the light that's all
around the object and illuminates it evenly from all directions.
Incident light is light that hits the surface from a particular direction;
light that hits directly (at a right angle) lights the object the most,
light that grazes the surface lights the object the least.  The angle
you *view* the surface from does not affect the brightness.  Specular
reflection is the "shininess" of the object.  Light bounces off the
surface and reaches your eye.  If you and the light source are close to
the same angle from the surface, the specular reflection is bright.

	eye	     light
           \        /
            \      /
             \    /
              \  /
        _______\/_______ surface


For example, paper has a low amount of specular reflection.  A polished
table has a high amount.

For color images, the ambient and incident reflections are the color of
the object; the specular reflection is the color of the light source.


so:

The object has three parameter that describe its appearance:  A coefficient
of incident reflection; Ci, a coefficient of specular reflection; Cs and an
exponent of specular reflection; Es.

Let A = the amount of ambient light.
I is the intensity of the light.
Let L be the vector from the surface to the light source.
E is the vector from the surface to the eye.
N is the normal vector for the surface.
R is the vector of light bouncing off the surface as if it were a mirror.
All vectors should be normalized.

R is calculated as R = 2N(N.L)-L 	["." is dot-product]
The amount of light received from ambient light is A*Ci
The amount of light received from incident light is I*Ci*(N.L)
The amount of light received from specular reflection is
I*Cs*(R.L)**Es

	Brightness = A*Ci + I*Ci*(N.L) + I*Cs*(R.L)**Es

If you have more than one light source, just sum over all of them.

Notes: Ci, Cs are values from 0 to 1.  Higher values make a brighter object.
Higher values of Cs make a shinier object.  Es varies from 8 to about 50.
Powers of two make easier computations.  Higher values make a "better
polished" impression.  Metal should have high values, things like billiard
balls should have medium values.  Experiment.

Color is not much harder.  In this case, Ci and I are (R,G,B) triples
(colored object, colored light).  Cs is still a scalar.
The red component would be

	Red = A*Ci(r) + I(r)*Ci(r)*(N.L) + I(r)*Cs*(R.L)**Es

and so forth.
		-ed falk, sun microsystems
		 sun!falk, falk@sun.com
terrorist, cryptography, DES, drugs, cipher, secret, decode, NSA, CIA, NRO.

milo@ndmath.UUCP (02/05/87)

Another related question...for those of you who have been involved in 
generating VERY complex images.  What is the typical amount of time/pixel 
invested in the generation of a complex ray-traced image?  Would it make
sense in the case of images that require hours of computer time to send
a copy of the database to a number of machines, then assign pixels to each
machine a few at a time?  That way you could distribute the processing over
a large number of CPU's but it would be easy to stop processing on a 
cpu who's load average (from other users) is on the rise.

Greg Corson
 

thomas@spline.UUCP (02/08/87)

I have done some ray tracing where it took upwards of 1 second per pixel. 
Under these circumstances, it made great sense to have different computers
compute different scanline groups.

=Spencer   ({ihnp4,decvax}!utah-cs!thomas, thomas@utah-cs.ARPA)