Homework 6

Justin Huang (cs184-en)

Gideon Chia (cs184-an)

So we enjoyed homework 5 (the raytracer) so much, that we decided to extend it.

On the raytracer side there were a couple things we decided to extend (it gets better towards the end):

Refraction

We generated refraction rays, by adding the command:

The command would give all the objects that follow it an index of refraction. When generating the refraction rays, we take the ratio of the index of refraction and input it into a formula, which gives the next direction. The image below demonstrates refraction.

scene4 refraction dragon refraction

Depth of Field

In order to accomplish depth of field, we introduce a couple more commands:

The focal command sets a point in space to be the focal point and sets the aperture. It combines the next 2 commands. The aperture command, sets the aperture, and the focal_depth command sets the depth of the focus. The DOF effect is accomplished by jittering the eye, by a certain amount(size of the aperture) in the u and v direction. The ray continues to go in the same direction to reach the focal point at focal_depth without the jittering. Below are some images generated with DOF.

scene4 dof scene4 dof

Animation

For animation, I didn't really animate any objects, but I do change the camera position and the up angle. I define a path using a set of points, and then draw a bezier curve through the points. This curve defines the path on which the camera follows as you can see in the video below. To create the video, I generate about 400 frames, and then stitch them together using ffmpeg, at roughly 30 frames per second.

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Also, introduced autofocus. It takes the middle pixel, and makes that it's focal point.

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

However, the effect was too abrupt so I introduced a gradual autofocus, that averages the previous couple of frames focal point.

[PLEASE WATCH IN HIGH DEF]

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Extra Credit: Extreme Parallelization

After introduction a lot more effects, raytracing became painfully slow, and making videos became even slower. In order to be able to still generate high quality videos, but be able to render them in less than a day, I decided to utilize the power of the hives. I wrote a small http server in python using the microframework: bottle. The server had a few simple get and put commands.

Then I wrote a client, which I ran on the hive machines. The clients would repeatedly curl the server, to see if there are any new jobs, if there are no more jobs they would automatically die. If there is a job, then it will render the scene file associated with the job, and then post the picture back to the server. This enabled me to render the following videos:

3 Area lights with a 50,000 triangle dragon with soft shadows, and depth of field. This took about 3 hours to render on 26 hive computers totaling 998.6 Ghz, and would have taken 12.5 days! to render on my computer with only 9.8Ghz.

[PLEASE WATCH IN HIGH DEF]

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

A 50,000 triangle dragon with refraction and depth of field. This took about 2 hours to render, and would have taken a week! to render on my computer.

[PLEASE WATCH IN HIGH DEF]

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

Extra Credit: 8 Filters

Justin wrote 8 filters that will be demonstarted on the video below. It took too much space on my disk to render, so I could only render half of the video. But, the video demonstrates 8 filters.

filters in this pattern:

1 2 3
4 5 6
7 8 9

  1. normal without filter
  2. pincushion distortion
  3. barrel distortion
  4. sepia filter
  5. gaussian blur
  6. grayscale
  7. color inversion filter
  8. horizontal blur
  9. edge detection algorithm

[PLEASE WATCH IN HIGH DEF]

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player