Here is a simple ray tracing program developed here at RPI. It incorporates shadows, reflections and refraction together with one non-directional light source. The light source can diffuse on the surfaces and can also give specular reflections. The illumination model used is by Phong. The only objects supported right now are spheres, but the data structure can be easily expanded to incorporate more objects. Here is a list of the files, and what does each file contain: bg.c: bgcolor() evaluates the background color for a given ray. initialize.c: initialize() does some useful setup. intersect.c: sphere() Intersection routine with a sphere. intersect() Main intersection routine (calls sphere() ). main.c: main() Main body of the program. readfile.c: readfile() Reads in the input data. shade.c: shadow() Calculates the existance of a shadow ray. reflect() Find the reflection vector. refract() Find the refraction vector. shade() Calculate Phong's shading function. trace.c: trace() Trace a single ray. raytrace() Ray trace the whole picture. vector.c: vadd() vector addition. vsub() vector subtraction. vneg() vector negation. svproduct() scalar - vector product. vdot() dot product. vcross() cross product. norm() normalize a vector. ray.h: Include file for every file used in the raytracer. vector.h: Include file for every file using vectors. The ray tracer is written so it can be easily understood (at least that version), and it is fully commented. Nevertheless, probably it won't be understood by a newcomer. The format of the input file is as follows: light nos x y z r [ambient] [diff] [spec] refl r g b refr r g b width index where: light x y z components of the light source. nos num,ber of spheres [ambient] r g b components of ambient [diff] r g b components of diffuse [spec] r g b components of specular refl r g b reflection ratio and color of the reflection refr r g b refraction ratio and color of the refraction width specular width exponent index index of refraction The format of the output file is simple. In the beginning there are 2 integers (that can be read with fread() on a SUN) showing xsize and ysize of the picture. After that follow the pixels in scan-line order. Each pixel uses 3 bytes (one for red, green and blue), totalling 16777216 colors. You can change the format of that file to tailor your needs. It can be done easily by changing the funcion raytrace() in file trace.c Can you please inform me with any bugs that the program might have or any features that you want the upcoming versions to have. This software was written by me, and the subsequent version will probably by produced by other members of the RPI chapter of the ACM. Good luck! George Kyriazis kyriazis@turing.cs.rpi.edu