Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!sri-unix!hplabs!pyramid!decwrl!cookie.dec.com!wecker From: wecker@cookie.dec.com (DAVE TANSTAAFL WECKER) Newsgroups: net.micro.amiga Subject: Ray tracing algorithm Message-ID: <6135@decwrl.DEC.COM> Date: Tue, 28-Oct-86 15:16:24 EST Article-I.D.: decwrl.6135 Posted: Tue Oct 28 15:16:24 1986 Date-Received: Wed, 29-Oct-86 08:48:40 EST Sender: daemon@decwrl.DEC.COM Organization: Digital Equipment Corporation Lines: 46 Several people have asked me to post a SHORT description of exactly what a ray tracing algorithm is.. so I'll try. Ray tracing is a technique for generating very "life like" images through one of the most compute intensive algorithms around. The basic steps are as follows: For each pixel on the screen: Set the pixel to black. Draw a vector from the position of your eye to the pixel. (Yes you can do steroscopic images by defining 2 eye positions) (a) Continue the vector until you hit something. Depending on the object you hit: Pass the vector through (with degradition along any RGB component, e.g. transmission of certain colors) applying any refraction coefficients for the object. Bounce the vector off of the object (with appropriate degradations and scatterings). If the object was a light source stop and back the vector out (back to the original pixel with computed RGB degradations) and add it to the pixel value. If the vector goes off the edges of the "world" throw it away. At this point you should have a bundle of vectors (bounced, scattered, bent). Take each new vector and recursively call (a) until you hit a maximum recursion depth. The cumulative value at the pixel is the correct RGB value to display (built up from all RAYS that hit that pixel on its way to your eye). That's pretty much it, there are however ALOT of got-ya's: - Usually, there is really no such thing as "black" so you you need to define an ambient lighting factor for all objects. - The algorithm above will give you the dreaded "jaggies" whenever there is a straight diagonal line in the picture. The images I sent out use a technique called "distributed ray tracing". This simply means that some number of rays are sent from the eye through the pixel (usually between 2 and 10) instead of 1. Each ray is slightly off center, so the net effect is to "blur" sharp edges avoiding the jaggies". - How many times do you let a ray bounce inside of a glass sphere before you give up on it? - Too many things to mention... you're all just going to have to wait until I get the AMIGA version completed.