POV-Ray : Newsgroups : povray.general : What would it take to get focal blur fixed? : What would it take to get focal blur fixed? Server Time
31 Jul 2024 20:15:17 EDT (-0400)
  What would it take to get focal blur fixed?  
From: dkleckner
Date: 23 Sep 2006 18:20:00
Message: <web.4515b204a2c88f9c1b1de3450@news.povray.org>
I noticed recently that focal blur has difficulty dealing with thin objects
which are out of focus, producing artifacts regardless of the number of
blur_samples and confidence/variance values.  To see a simple example of
this, render the following code:

#include "colors.inc"

global_settings {assumed_gamma 1.0}

camera {
 location 0
 look_at   z
 focal_point z*5
 aperture .5
 blur_samples 200
 confidence 0.9999
 variance 1/100000
}

#declare i = 1;
#while(i < 30)
 sphere{<i*i/30 - i/2, 0, i>, .01*i pigment {color White} finish {ambient
1}}
 sphere{<i*i/30 - i/2, i/3, i>, .1 pigment {color White} finish {ambient 1}}
 torus{.05 * i, .001 * i pigment {color White} finish {ambient 1} rotate x *
90 translate <i*i/30 - i/2, -i*(1/6+mod(i, 4)/15), i>}
 #declare i = i + 2;
#end

Even worse, turning the number of blur samples down can actually make it
look better.  The artifact seems to realize it self exactly at blur_samples
19 (try 18 and 19, and compare!).  I had a look at the source code, at it
seems to happen because of some strange hexagon-shaped grid which is used
to decide on the points from which to shoot rays to calculate the focal
blur.  (There is also a comment in there indicating "this should probably
be changed!")

It seems to me that it would be _very_ easy to rewrite this code, using a
monte-carlo (i.e. random) approach to determine where in the aperature to
send rays from.  This would also make it very easy to allow control of the
bokeh (shape of the defocus), which would make focal blur look like it does
in an actual photograph.  The monte-carlo method should also converge more
rapidly on the ideal result than a grid-based method, allowing cleaner
looking focusses in less time even in situations where the defect doesn't
show up.

I'd do all of this myself, as it wouldn't take long, but even figuring out
how to get the source code to compile seems like a major project.  So are
any of the main POV programmers interested in giving it a shot?  It seems
to me that this is a serious flaw in the POV renderer, and it would benefit
greatly from it being fixed in the main release.  I'd be more than happy to
contribute advice and testing.


Post a reply to this message

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