POV-Ray : Newsgroups : povray.binaries.images : focal blur technique, probably nothing new... Server Time
8 Aug 2024 14:17:16 EDT (-0400)
  focal blur technique, probably nothing new... (Message 1 to 2 of 2)  
From: triple r
Subject: focal blur technique, probably nothing new...
Date: 29 May 2005 11:20:00
Message: <web.4299dcdc20345e88e702b90a0@news.povray.org>
Over lunch yesterday, I was wondering whether a system of lenses could focus
and produce an image for raytracing.  The simple answer is yes.  This first
image of two spheres is not from pov-ray, but is just a very simple
raytracer with one light, two spheres, phong, and diffuse lighting.

The setup is something like |x|__o with the film plane, the rays cross, then
a lens, then a sphere.  For each pixel on the film, points across the lens
are sampled since they all contribute a ray of light.  Of course, because
it's perfectly in focus, all of the rays go through the point in focus in
the scene corresponding to that point on the film, if that makes any sense.
 Simple average.

Only after I did it and thought about it, I realized it does exactly what
pov-ray's focal blur does, just without the corresponding physics layed out
as explicitly.  The difference is that pov-ray only has a square aperture,
so the bokeh (look it up) is perfectly square and kinda ugly.  So I used a
curved pentagonal aperture applied directly to the lens for the first
image.

The second image is from pov-ray, but with an aperture very close to the
camera.  It isn't nearly as efficient as an aperture directly coded into
the raytracer, but does the job, with a lot of samples and some vignetting.
 Just thought I'd share since it could be a good technique for dramatic
closeups.

Here's the source.  Sorry for the long email.  With my raytracer, I think
I'm gonna experiment with more complicated lens setups and better physical
models for lenses since the physical model is already there.  Fun, although
it'll probably go the way of all my other projects due to time
constraints...

 - Ricky


background{rgb 0}
camera {
 perspective
 up y right x
 location <0,0,0>
 angle 48
 look_at <0,0,3>
 focal_point <0,0,-.5>
 aperture 0.35 //A little larger than the physical aperture
 blur_samples 800
 //takes a lot to look smooth since they are just random,
 //not an array like an area light
}
light_source{<15,25,-25> rgb 0.5}
light_source{<30,2,-25> rgb 0.5}
light_source{<45,45,-0> rgb 0.5}

difference{
 box{<-5,-.0001,-5>,<5,.0001,5>}
 intersection{
  #declare curvature = 0.25;
  #declare blades = 5;
  #declare ang = 0;
  #while(ang < 360)
   cylinder{-y*0.001,y*0.001,1/curvature
   //intersection of circles form the aperture
   translate (1/curvature-1.0)*x
   rotate y*ang
   }
   #declare ang = ang+360/blades;
  #end
 }
 scale 0.07  //small
 rotate x*90 //in plane perp. to the camera
 translate z*.001 //and very close to the camera
}
union{
 sphere{<0,0,3>,1}
 sphere{<.015,.015,.529>,.02}
 sphere{<-.12,-.14,0.78>,.11}
 sphere{<-.12,.12,0.6>,.05}
 pigment{rgb 1} finish{diffuse .7 phong 50 phong_size 1100}
 //very strong, sharp phong for the effect
}


Post a reply to this message


Attachments:
Download 'bokeh.jpg' (12 KB)

Preview of image 'bokeh.jpg'
bokeh.jpg


 

From: triple r
Subject: Re: focal blur technique, probably nothing new...
Date: 29 May 2005 11:40:01
Message: <web.4299e13a2f4214e3e702b90a0@news.povray.org>
Image number two, rendered with the given pov-ray code:


Post a reply to this message


Attachments:
Download 'bokeh2.jpg' (13 KB)

Preview of image 'bokeh2.jpg'
bokeh2.jpg


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.