I have been working slowly these days probably due to the hot temperature in Tunisia,anyway i have just implemented DOF and i thought  that i can share my progress,nothing out of the extraordinary, it’s just a simple scene but I’m willing to expand the ray tracer by adding an xml-parser probably, but nothing is for sure…

I think depth of field is not well explained in most of cg papers that’s why I’ll shortly describe the algorithm to calculate it:

  • First ,we need to specify how farther our focal plane is from the camera origin (this is called the focal distance)
  • Second ,we calculate our ray direction as we normally do
  • Third,we calculate our point in focus for that given pixel (point=ray.origin+ray.direction*focal_distance)
  • Fourth,we calculate a random point on the lens and displace the ray origin by the coordinates of this point
  • Finally ,the new ray direction is ( point-ray.origin).normalize()

Sorry for the excessive use of the word “calculate” :D

Here’s my results:

Cornell Box+DOFOutdoor+DOF

Thanks to lyc ,I’m now interested in fractals ,I wrote a program to render the Mandelbrot set and the Julia set ,it’s  quite an easy task ,what impress me though is that how such simple formulas (Zn+1=Zn*Zn+C where Zn+1,Zn and C are complex numbers) can generate very beautiful shapes.

The first image represents the Mandelbrot set, the second and the third ones are the Julia set with different values of C.

Mandelbrot set

Julia set 1Julia set 2

Advertisement