ray trace movie
another ray trace movie
raytraced ball moving through space (the matlab
conversion has badly decreased the quality somehow)
How the raytracer works (pseudocode):
for every pixel
compute a ray
for every sphere
if it intersects the ray
closer than all previous spheres, reassign closest_sphere and min_t
end
for every plane
if it intersects the ray
closer than all previous spheres and planes, reassignments
end
if there was an intersection for this ray (since
planes are infinite, this is almost always true)
get normal and view information
and the intersection point for that object
for every light
cast a ray from the point to the light and see if there is an intersecting
object (for
every sphere, for every plane, like before)
if the point is not in shadow for that light
calculate lighting on that point from that light, and add it to the color
of the pixel.
end
end
end
end
Conclusion:
Getting the initial raytracer to work was very easy, but adding bits
of matlab code for
shadows and plane rendering made it frustratingly slow to wait for
output to see if it was
correct. To avoid flooding color for the random raytraced images,
I had to make a lot of
restrictions that basically make the random spheres very similar except
for color. For the
first raytrace movie above, I did a cubic interpolation between four
of the light sources via
the method we've learned in class. In the third movie, the sphere
follows a rising spiral
within the rendering volume, but occasionally all of the sphere is
not within the volume. As
you can see this is not a problem.
(an additional light)