The project is built based on the ray tracer from Project 3-1. The renderer is now able to render mirror and glass models, and can also render with depth of field effect.
The implementation of mirror models involves perfect specular reflection of the light, and glass models involves refraction. In the part of depth of field, I used a thin lens camera model instead of the pinhole camera model, to achieve the focus effect. After implementing these parts, I now have a better understanding of the relationship between the material and the light.
Below is a sequence of images of CBspheres.dae, rendered with max_ray_depth equals to 0, 1, 2, 3, 4, 5, and 100, 64 samples per pixel and 4 samples per light.
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
When max_ray_depth = 0, there is only light from the ceiling shown, because we can only see the objects directly emitting the light to the camera.
When max_ray_depth = 1, not only the objects directly emitting the light are shown, but also the objects having rays bounced once to the camera. Thus, the room and the ceiling light’s reflections on the spheres are shown.
When max_ray_depth = 2, the image shows the mirror and the glass. The glass is dark because there is not adequate bounce going through. Also in the reflection of mirror, the glass sphere is very dark and not translucent.
When max_ray_depth = 3, the image becomes brighter. Both the mirror and glass spheres are shown better. We can see through the glass sphere, but it is still little dark, and it is even darker in the reflection of the mirror.
When max_ray_depth = 4, the image has better performance on both spheres. The glass sphere becomes more translucent. In the reflection of the mirror, we start to see through the purple wall from the glass ball. We can also see the bright spot on the right wall, refracted by the glass ball.
When max_ray_depth = 5, the refraction on the right wall is more obvious.
When max_ray_depth = 100, the image doesn’t have large difference with the one when max_ray_depth = 5. Both of the actual glass sphere and the one in the mirror are a little brighter, and translucent enough.
A pinhole camera model is an ideal model that the camera aperture is only a point. Only the ray going though this point is traced, and then the three-dimensional world is projected on the image plane. The ray wouldn’t change its direction when passing the aperture. Also, no matter its distance to the camera, everything is in focus. On the other hand, a thin-lens camera model has a lens with a focal distance. Although the actual thickness of the lens is ignored, the rays passing through the lens will change the direction (except the ray passing through the lens’ center). Only the objects within this distance are in focus. A thin-lens camera is more like the camera in reality, and it provides a more realistic outcome than a pinhole camera model.
Below is a series of images that focus at 4 different depths with the same aperture size. We can tell that as the depth increases, the focused portion is gradually moving backwards.
![]() |
![]() |
![]() |
![]() |
Below is a series of images that have different aperture sizes, focused at the same point. We can tell that as the aperture size increases, the background becomes more blurry, and the focused area is smaller.
![]() |
![]() |
![]() |
![]() |