ray_trace
function.
A suggested progression can be as follows.
diffuse
material component is not
zero, iterate through the list of lights in the scene
find_closest
function)
find_closest
function)
0
and
less than 1
, compute Id
which is the light color scaled by
N · L divided by
the distance to the light r, i.e.,
(N · L)/r
clamp: lo: hi
for the pixel_t
type)
specular
material component is not
zero, compute the reflective color obtained
a recursive call to ray_trace
followed by adding in specular highlights
(see below; in this step just put in a placeholder
for the recursive call and add in the specular
highlights first)
specular
material component is not
zero, iterate through the list of lights in the scene
find_closest
function)
find_closest
function)
0
and
less than 1
, compute Is
which is the light color scaled by
(R · V)n
divided by the distance to the light r, i.e.,
(R · V)n/r
ray_trace
to produce the final image:
pixel_t *refcolor
pixel vector
which will hold the color returned by the
ray_trace
call
out
the reflection direction vector,
2 (N · -dir) N - -dir
(don't forget to normalize)
ray_trace
with hit
and out
acting acting as the
ray position and direction, along with
raydist
being passed-by-value
(this is used to cull the ray if the ray distance
is too large, e.g., 100)
color
and
refcolor
by multiplying color
by diffuse
and refcolor
by specular
and adding
cbox.txt
camera cam { pixeldim 512 384 worlddim 5.12 3.84 viewpoint 2.56 2 5 } light top { location 2.56 3.80 -1.5 emissivity 1 1 1 } material gray { ambient 3 3 3 diffuse .9 .9 .9 } material green { ambient 0 5 0 diffuse 0 .5 0 } material salamander { ambient 3 2 2 diffuse .9 .9 .9 } material slate { ambient 2 1.8 3 diffuse .9 .9 .9 } material transparent { ambient 3 3 3 diffuse .1 .1 .1 specular .9 .9 .9 alpha .9 ior 1.83 } material chrome { ambient 3 3 3 diffuse .1 .1 .1 specular .9 .9 .9 } plane backwall { material gray normal 0 0 1 point 0 0 -5 } plane leftwall { material salamander normal 1 0 0 point 0 0 0 } plane rightwall { material slate normal -1 0 0 point 5.12 0 0 } plane ceiling { material gray normal 0 -1 0 point 0 3.84 0 } plane floor { material gray normal 0 1 0 point 0 -0.2 0 } sphere left { material chrome center 1.25 .75 -4 radius .9 } sphere right { material transparent center 3.7 .7 -2.3 radius .9 }
tar.gz
archive of your asg8/ directory, including:
README
file containing
Makefile
.h
headers and .c
source)
make clean
before tar
)
submit
notes.