Dec 192017
C source for a simple ray tracer.
File TRACER.ZIP from The Programmer’s Corner in
Category C Source Code
C source for a simple ray tracer.
File Name File Size Zip Size Zip Type
BDATA.I 213 77 deflated
CONV.C 824 453 deflated
EXTERN.H 130 89 deflated
FIND.C 1942 670 deflated
G_BAL.C 652 286 deflated
G_BOD.C 595 307 deflated
MACROS.H 1116 550 deflated
MAKEFILE 536 169 deflated
README.DOC 2252 1022 deflated
README.HAK 1259 660 deflated
REFRACT.C 2965 906 deflated
RTD.H 434 168 deflated
SHADE.C 3454 1376 deflated
SUPPORT.C 834 253 deflated
TRACER.C 2624 1038 deflated

Download File TRACER.ZIP Here

Contents of the README.DOC file


tracer- run a simple ray tracing procedure

tracer -o [filename] -i [filename] -s -S

Tracer is a program developed originally to study how
ray tracing works, and was later modified to the present state
to make it more compatible for animated film production.

It is capable of depicting a number of balls (up to 150)
and a plane that is covered with a tiling of any bitmapped picture.

-o Chooses the output data file. If no argument is givin, stdout
is used. If the option is not used the default is data.dis.

-i Chooses the input (ball) data file. If no argument is given, stdin
is used. If the option is not used the default is bdata.i.

-s Chooses the file containing the tiling bitmap. It requires an
an argument. If the option is not used the default is pat.def.

-S Chooses contrast of the pattern. 0.0 is no contrast, 1.0 is maximum
contrast. 1.0 is the default. (useful for fading during animation)

This program generates a file containing a header with x and y sizes,
followed by the data in 8-bit greyscale, one pixel to a character, in
There are two neccessary input files: ball data, and a pattern bitmap.
The tiling bitmap can be digitized data, it must be in the form of
scan lines no longer than 512 bytes followed by newlines.
the ball data is of the following form:

x y z rad ior refract reflect diffuse ambient

on each line where x y & z are the coordinates of the center of
the ball, rad is the radius of the ball, ior is the index of refraction
for translucent materials (index of refraction for glass is about 1.5)
the last four numbers determine how much of each atrribute is used.
Thus a pure silver ball would have 0.0 1.0 0.0 0.0 as the last numbers,
and a pure glass ball would have 1.0 0.0 0.0 0.0 .

./bdata.idefault ball data
./pat.def default floor pattern
./data.dis default output file

As with any good software, the complexity of this program hides
all bugs.

 December 19, 2017  Add comments

Leave a Reply