![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
A simple macro I put together that approximates a 35mm camera in the scene.
Should do the correct field of view and a vaguely plausible focal blur. Feel
free to fix any obvious (and even not so obvious) flaws...
The example picture uses a 50mm lens at f1.4. The three balls are 100mm in
diameter, with the center ball 500mm from the camera. The checkerboard is 100mm
per square.
#macro Camera35mm( cam_pos, look_pos, focal_length, fstop, num_samples )
#local film_width = 35;
#local fov = degrees( atan( (film_width / 2) / focal_length ) * 2 );
#local apertureDiameter = focal_length / fstop;
#local focal_distance = vlength( look_pos - cam_pos);
camera {
perspective
focal_point look_pos
blur_samples num_samples
aperture (apertureDiameter / focal_distance) * 1000 // Magic Number
location cam_pos
look_at look_pos
angle fov
right x * 1
up y * image_height/image_width
}
#end
Cheers,
Edouard.
Post a reply to this message
Attachments:
Download '50mm_f1.4.jpg' (136 KB)
Preview of image '50mm_f1.4.jpg'
![50mm_f1.4.jpg](/povray.binaries.images/attachment/%3Cweb.49a52c329791b720bd47b0730%40news.povray.org%3E/50mm_f1.4.jpg?ttop=443866&toff=2850&preview=1)
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> The example picture uses a 50mm lens at f1.4. The three balls are 100mm in
> diameter, with the center ball 500mm from the camera. The checkerboard is 100mm
> per square.
And another - same geometry, but using a 105mm lens at f/5.6.
Post a reply to this message
Attachments:
Download '105mm_f5.6.jpg' (82 KB)
Preview of image '105mm_f5.6.jpg'
![105mm_f5.6.jpg](/povray.binaries.images/attachment/%3Cweb.49a52ef955a0132ebd47b0730%40news.povray.org%3E/105mm_f5.6.jpg?ttop=443866&toff=2850&preview=1)
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
This is nice little tool.
The only thing that's missing (not from the standpoint of your code, though) is
that POV's blur doesn't *seem* to take into account the 'hyperfocal distance'
of a real lens. I.e., I think that the amount of blur on either side of the
in-focus plane progresses linearly in and out from that point (when it should
do so non-linearly? At least on the +z side of that sharp plane, to 'stretch
out' the amount of blur there--over a longer distance--in order to match the
qualities of a real lens.) I could be wrong about this, but it's been my own
experience, visually.
Ken W.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
It is probably my misunderstanding of your macro, but I get weird results.
In particular by just changing fstop, the camera seems to jump from inside
one of the objects to outside. So, how do you define the parameters? just as
in RL photography? i.e. focal_length is 50 or 105; fstop is 1.4 or 16?
Thomas
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"Kenneth" <kdw### [at] earthlink net> wrote:
> This is nice little tool.
>
> The only thing that's missing (not from the standpoint of your code, though) is
> that POV's blur doesn't *seem* to take into account the 'hyperfocal distance'
> of a real lens. I.e., I think that the amount of blur on either side of the
> in-focus plane progresses linearly in and out from that point (when it should
> do so non-linearly? At least on the +z side of that sharp plane, to 'stretch
> out' the amount of blur there--over a longer distance--in order to match the
> qualities of a real lens.) I could be wrong about this, but it's been my own
> experience, visually.
I'm not sure I agree. POV-Ray's lens model is consistent with a thin-lens
approximation, and should simulate all of the appropriate physics. Even with
the nonlinear effects though, it should be roughly linear close to the focal
point.
- Ricky
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote:
> It is probably my misunderstanding of your macro, but I get weird results.
> In particular by just changing fstop, the camera seems to jump from inside
> one of the objects to outside. So, how do you define the parameters? just as
> in RL photography? i.e. focal_length is 50 or 105; fstop is 1.4 or 16?
>
> Thomas
Yes - it should work like that. Since the camera is declared in mm, the rest of
the scene has to be in mm as well. Or you can change the camera to be 0.05
meters if you scene is in meters of course.
fstop is 1.4 or 16 as you say.
One sort of limitation is that I've only got a camera and look_at position. The
focal plane goes through the look_at position, which made sense for me, but the
macro could be changed to have a separate focal point, or a focal distance.
Future plans:
o Another macro to automatically focus at the hyperfocal distance
o Take the image size into account for the "circle of confusion" (in the
hyperfocal case)
o Auto-focus! Give the camera an object, and use trace() to focus on it
o Also post my Stochastic Render Rig version of the same macro (just got to
tweak the AA values a bit more).
Here's the scene:
#include "transforms.inc"
#macro Camera35mm( cam_pos, look_pos, focal_length, fstop, num_samples )
#local film_width = 35;
#local fov = degrees( atan( (film_width / 2) / focal_length ) * 2 );
#local apertureDiameter = focal_length / fstop;
#local focal_distance = vlength( look_pos - cam_pos);
camera {
perspective
focal_point look_pos
blur_samples num_samples
aperture (apertureDiameter / focal_distance) * 1000 // Magic Number
location cam_pos
look_at look_pos
angle fov
right x * 1
up y * image_height/image_width
}
#end
#declare cam_pos = < 0, 150, -500 >; // in mm
#declare look_pos = < 0, 50, 0 >; // in mm
#declare lens = 50; // mm
#declare f_ratio = 4; // Aperture as f ratio
#declare num_samples = 19; // 7, 19 & 37 happen to be hexagonal
Camera35mm( cam_pos, look_pos, lens, f_ratio, num_samples )
light_source {
<10000,20000,-2000>
rgb 1
}
sphere {
0, 50
pigment { rgb <0.2, 1, 0.2 > }
finish { specular 1 roughness 0.001 reflection 0.5 }
translate <66, 50, 100>
}
sphere {
0, 50
pigment { rgb <1, 0.2, 0.2 > }
finish { specular 1 roughness 0.001 reflection 0.5 }
translate <0, 50, 0>
}
sphere {
0, 50
pigment { rgb <0.2, 0.2, 1 > }
finish { specular 1 roughness 0.001 reflection 0.5 }
translate <-66, 50, -100>
}
plane {
<0.0, 1.0, 0.0>, 0.0
pigment {
checker
rgb <0.123, 0, 0.998>, rgb <0.107, 0.993, 0>
scale 100 // every 10cm
}
finish {
diffuse 0.6
}
}
sky_sphere {
pigment {
gradient y
color_map {
// http://povray.tashcorp.net/tutorials/qd_realskysphere/
[ 0/269 color rgb <120/255, 79/255, 51/255>]
[ 1/269 color rgb <141/255, 83/255, 46/255>]
[ 2/269 color rgb <177/255, 86/255, 41/255>]
[ 3/269 color rgb <235/255,128/255, 72/255>]
[ 5/269 color rgb <255/255,159/255, 72/255>]
[ 8/269 color rgb <255/255,203/255, 94/255>]
[ 10/269 color rgb <255/255,218/255,112/255>]
[ 13/269 color rgb <255/255,233/255,148/255>]
[ 15/269 color rgb <251/255,241/255,172/255>]
[ 20/269 color rgb <255/255,246/255,203/255>]
[ 30/269 color rgb <255/255,240/255,219/255>]
[ 40/269 color rgb <236/255,223/255,214/255>]
[ 50/269 color rgb <205/255,204/255,212/255>]
[ 55/269 color rgb <185/255,190/255,209/255>]
[ 60/269 color rgb <166/255,176/255,201/255>]
[ 65/269 color rgb <149/255,163/255,190/255>]
[ 70/269 color rgb <129/255,149/255,182/255>]
[ 80/269 color rgb <103/255,127/255,171/255>]
[ 90/269 color rgb < 79/255,110/255,154/255>]
[100/269 color rgb < 66/255, 97/255,143/255>]
[110/269 color rgb < 52/255, 84/255,131/255>]
[120/269 color rgb < 47/255, 75/255,122/255>]
[140/269 color rgb < 37/255, 60/255,102/255>]
[160/269 color rgb < 32/255, 51/255, 84/255>]
[180/269 color rgb < 27/255, 42/255, 71/255>]
[200/269 color rgb < 25/255, 36/255, 58/255>]
[220/269 color rgb < 22/255, 31/255, 48/255>]
[240/269 color rgb < 18/255, 27/255, 42/255>]
[260/269 color rgb < 15/255, 21/255, 33/255>]
[269/269 color rgb < 15/255, 21/255, 33/255>]
}
}
}
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"triple_r" <nomail@nomail> wrote:
> "Kenneth" <kdw### [at] earthlink net> wrote:
> > This is nice little tool.
> >
> > The only thing that's missing (not from the standpoint of your code, though) is
> > that POV's blur doesn't *seem* to take into account the 'hyperfocal distance'
> > of a real lens. I.e., I think that the amount of blur on either side of the
> > in-focus plane progresses linearly in and out from that point (when it should
> > do so non-linearly? At least on the +z side of that sharp plane, to 'stretch
> > out' the amount of blur there--over a longer distance--in order to match the
> > qualities of a real lens.) I could be wrong about this, but it's been my own
> > experience, visually.
>
> I'm not sure I agree. POV-Ray's lens model is consistent with a thin-lens
> approximation, and should simulate all of the appropriate physics. Even with
> the nonlinear effects though, it should be roughly linear close to the focal
> point.
>
> - Ricky
I agree with Ricky - while the POV focal blur system has it's flaws, I think it
gets the actual blur amount in front of and behind the focal plane correct.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"Edouard Poor" <pov### [at] edouard info> wrote:
> #macro Camera35mm( cam_pos, look_pos, focal_length, fstop, num_samples )
> #local film_width = 35;
Opps - there's a bug right there!
It should of course be:
#local film_width = 36;
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"Edouard Poor" <pov### [at] edouard info> wrote:
> I agree with Ricky - while the POV focal blur system has it's flaws, I think
> it gets the actual blur amount in front of and behind the focal plane correct.
The concept of 'hyperfocal distance' has been with me since I was a teenager,
when I used to shoot lots of B&W 35mm stills. But I decided to look up the
actual definition(!) To my surprise, there are *two* definitions, both equally
valid (if slightly different as to the 'acceptable focus' range.) The first
assumes setting the camera focus at a point somewhere off in the distance
(though not at infinity) to get the maximum focus-range from 1/2 that distance
*to* infinity. The other assumes setting the camera focus *at* infinity, which
produces a nearly equal 'acceptable focus' range. (My own concept has always
been the former one.)
I looked at the actual equations for both 'hyperfocal distance' and the
'thin-lens approximation', and I'm still wondering if POV-Ray takes it all into
account. (I'm no optician, so I'm still trying to get the hang of how the two
equations are coupled together.) I guess I should just set up a POV test scene
looking at objects that proceed off into the distance, and just *see* if POV's
blur does mimic HD.
One thing I did come across was that hyperfocal distance is intimately tied to
the size of the film frame itself (or the size of the CCD sensor in a digital
camera), in relation to the lens diameter or focal length--or something like
that. For hyperfocal distance to have any meaning at all in the POV world, one
would have to assume that POV's rendered image size (say, 640 X 480 pixels)
*is* the film or sensor 'size'. I guess that's obvious, I don't know.
KW
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
"Kenneth" <kdw### [at] earthlink net> wrote:
> "Edouard Poor" <pov### [at] edouard info> wrote:
>
> > I agree with Ricky - while the POV focal blur system has it's flaws, I think
> > it gets the actual blur amount in front of and behind the focal plane correct.
>
> The concept of 'hyperfocal distance' has been with me since I was a teenager,
> when I used to shoot lots of B&W 35mm stills. But I decided to look up the
> actual definition(!) To my surprise, there are *two* definitions, both equally
> valid (if slightly different as to the 'acceptable focus' range.) The first
> assumes setting the camera focus at a point somewhere off in the distance
> (though not at infinity) to get the maximum focus-range from 1/2 that distance
> *to* infinity. The other assumes setting the camera focus *at* infinity, which
> produces a nearly equal 'acceptable focus' range. (My own concept has always
> been the former one.)
>
> I looked at the actual equations for both 'hyperfocal distance' and the
> 'thin-lens approximation', and I'm still wondering if POV-Ray takes it all into
> account. (I'm no optician, so I'm still trying to get the hang of how the two
> equations are coupled together.) I guess I should just set up a POV test scene
> looking at objects that proceed off into the distance, and just *see* if POV's
> blur does mimic HD.
>
> One thing I did come across was that hyperfocal distance is intimately tied to
> the size of the film frame itself (or the size of the CCD sensor in a digital
> camera), in relation to the lens diameter or focal length--or something like
> that. For hyperfocal distance to have any meaning at all in the POV world, one
> would have to assume that POV's rendered image size (say, 640 X 480 pixels)
> *is* the film or sensor 'size'. I guess that's obvious, I don't know.
I understood the hyperfocal distance to be the same as you - where the most
distant area that could be considered to be in focus happened to be infinity.
As for calculating the hyperfocal distance in POV, you're right, the resolution
of the image can be taken into account - but that equates to the circle of
confusion (the size at which you cannot tell if a pixel is in focus or out of
focus). For 35mm film, that is often taken to be around 0.03mm. For a render,
it would usually be one pixel, but if you rendered a very large image and
displayed on a high res device (or printed it at very high res), it could be
more than a pixel.
The "film size" or "sensor size" also needs to be taken into account, along with
the lens size etc, for the actual calculations, but that's different from the
resolution of that virtual sensor or film.
Like I said, that's one of the improvements I'd like to make. I'll have a play
with the maths this weekend. I'm not actually very good at maths, but the web
has literally thousands of pages on this stuff, so it shouldn't be too hard.
Cheers,
Edouard.
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |