POV-Ray : Newsgroups : povray.binaries.images : 35mm Camera Macro : Re: 35mm Camera Macro Server Time
1 Aug 2024 06:24:39 EDT (-0400)
  Re: 35mm Camera Macro  
From: Edouard Poor
Date: 28 Feb 2009 05:10:01
Message: <web.49a90d5655a0132ebd47b0730@news.povray.org>
I wrote:

> A simple macro I put together that approximates a 35mm camera in the scene.

Updated macros - with a major bug fixed in the Camera35mm macro (I was putting
the distance to the focal point in the calculation of the aperture - which was
a hang over from my stochastic code, but completely wrong for the POV focal
blur).

I've also done a couple of Hyperfocal versions of the macro - one that takes the
image sensor (i.e. the picture resolution) into account, and one that doesn't
(and sets the circle of confusion to 0.03mm, which is roughly the right value
for 35mm film).

Any other additions people would like?


#macro Camera35mm( cam_pos, look_pos, focal_length, fstop, num_samples )
 #local film_width = 36;
 #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 ) * 2  // Magic Number

  location cam_pos
  look_at look_pos
  angle fov
  right x * 1
  up y * image_height/image_width
 }
#end

#macro HyperfocalCamera35mm( cam_pos, look_pos, focal_length, fstop, num_samples
)
 #local film_width = 36;
 #local fov = degrees( atan( (film_width / 2) / focal_length ) * 2 );
 #local apertureDiameter = focal_length / fstop;
 #local look_distance = vlength( look_pos - cam_pos);
 #local circle_of_confusion = film_width / image_width;
 #local hyperfocal_distance = ((focal_length * focal_length) / (fstop *
circle_of_confusion)) + focal_length;
 #debug concat( "Field of View is ", str( fov, 0, 1 ), " degrees\n" )
 #debug concat( "Circle of confusion is ", str( circle_of_confusion, 0, 2 ),
"mm\n" )
 #debug concat( "Hyperfocal distance is ", str( hyperfocal_distance, 0, 0 ),
"mm\n" )
 #debug concat( "Min distance in focus is ", str( hyperfocal_distance/2, 0, 0 ),
"mm\n" )

 camera {
  perspective

  focal_point ((cam_pos - look_pos) / look_distance) * hyperfocal_distance
  blur_samples num_samples
  aperture (apertureDiameter) * 2  // Magic Number

  location cam_pos
  look_at look_pos
  angle fov
  right x * 1
  up y * image_height/image_width
 }
#end

#macro HyperfocalCamera35mm_fixed_circle_of_confusion( cam_pos, look_pos,
focal_length, fstop, num_samples )
 #local film_width = 36;
 #local fov = degrees( atan( (film_width / 2) / focal_length ) * 2 );
 #local apertureDiameter = focal_length / fstop;
 #local look_distance = vlength( look_pos - cam_pos);
 #local circle_of_confusion = 0.03; // std circle of confusion for 35mm film
 #local hyperfocal_distance = ((focal_length * focal_length) / (fstop *
circle_of_confusion)) + focal_length;
 #debug concat( "Field of View is ", str( fov, 0, 1 ), " degrees\n" )
 #debug concat( "Circle of confusion is ", str( circle_of_confusion, 0, 2 ),
"mm\n" )
 #debug concat( "Hyperfocal distance is ", str( hyperfocal_distance, 0, 0 ),
"mm\n" )
 #debug concat( "Min distance in focus is ", str( hyperfocal_distance/2, 0, 0 ),
"mm\n" )

 camera {
  perspective

  focal_point ((cam_pos - look_pos) / look_distance) * hyperfocal_distance
  blur_samples num_samples
  aperture (apertureDiameter) * 2  // Magic Number

  location cam_pos
  look_at look_pos
  angle fov
  right x * 1
  up y * image_height/image_width
 }
#end


Post a reply to this message

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