
Practice problems - set 2
1. Let’s say you want to use ray tracing algorithm for a scene where the light source is a directional light
source rather than a point light source. Describe what needs to be changed and how.
Recall that directional light source is essentially a point light source at infinity. For a directional light
source, the light rays are parallel, i.e. light is arriving to any point from the same direction ~
b.
2. Describe how you would extend the ray tracer you are implementing for the first project to include
objects that are perfect mirrors, maybe a few triangles and spheres. Be concise and specific: concentrate
on how to compute a color for some pixel.
3. Let’s say you want to use the ray tracing algorithm for a parallel rather than pewspective view. Parallel
view basically means that the viewpoint is at infinity (in the direction ~e). Describe the differences of the
parallel view variant of ray tracing and the perspective variant that was discussed in class.
4. Take a perfectly diffuse sphere with center c= (cx, cy, cz) and radius R, lit by a point light source at
l= (lx, ly, lz). Assume that lis outside the sphere and all this happens in a universe where light source
attenuation does not happen and the diffuse illumination is governed by the formula described in class.
Which point on the sphere will appear the brightest to an observer wandering around it? Explain your
answer. Give a formula for the brightest point.
How would your answer change in presence of light source attenuation?
5. Take a sphere centered at cwith radius R. Let the viewpoint be at eand the light source at b. You
know that the distance between the viewpoint and the center of the sphere is the same as the distance
between the light source and the center of the sphere and that the light source can be seen from the
viewpoint.
1. Assuming that only ambient and diffuse terms are used for illumination, which point on the sphere
appears brightest? Give a formula for that point.
2. Assuming that only ambinet and specular terms are used for illumination, which point on the sphere
appears brightest? Give a formula for that point.
6. When we described our simple ray tracer, we assumed that the viewpoint and light source are outside
any sphere. Now, let’s say that we want relax all these assumptions and allow them to be inside some of
the spheres. Let’s say that the closest intersection point pof the eye ray and the primitives happens to
lie on a sphere with center at cand with radius R, the light source is at point band the viewpoint is at e.
Write a concise pseudocode that would compute the normalized normal vector Nat pthat one should use
for illumination calculations (recall that the viewpoint may be inside the sphere!). In your pseudocode, you
can conditional statements, use the standard vector operations (dot product, cross product, magnitude
of a vector (||.||)), add or subtract points/vectors or multiply them by a scalar and use arithmetic or
comparison operators.
1