POV-Ray : Newsgroups : povray.advanced-users : More on vignetting in the camera lens Server Time
25 Nov 2024 09:57:38 EST (-0500)
  More on vignetting in the camera lens (Message 1 to 2 of 2)  
From: Don Barron
Subject: More on vignetting in the camera lens
Date: 9 Feb 2003 16:55:04
Message: <web.3e46cd6ece30e63ceb37bc10@news.povray.org>
I attach a further improved version of the algorithm of Messrs Slime and
Hughes.  It now scales correctly for any camera angle and can use any
arbitrary vignetting function. There are built-in calibration objects to
verify the simulation.

/*-- Validating the algorithms for vignetting in the camera lens-----.

The earlier model by Hughes, based on a suggestion by Slime, and which is
the basis of this present file, did not scale correctly. Vignetting did not
occur outside the cylindrical region defined by the texture.  So, I drilled
a hole in a very thin black box with the inverse of the textured sphere and
filled the hole with the textured sphere.

There's a series of sphere objects and a pair of boxes in a rectangular
scene geometry to test the vignetting code.  There are three types of
vignetting
functions built into this file for illustration purposes:

(1) a linear function of the radial distance, to keep it simple to
measure in PaintShopPro  the accuracy of the vignette.
(2) a sqrt(cos) function
(3) a cos^4 function ( which is the brightess of an image created by a
    pinhole lens without vignetting!) In this case the image is rendered as
a
    16bit height field....but is only realistic for a 180deg field
*/

#declare VigFunc = 2;
global_settings { assumed_gamma 2.2
                  #if(VigFunc = 3) hf_gray_16 #end
                }

#declare CamHfov =  50;      // Horizontal field of view of camera..select
to your choice
#declare CamLocn =  -z*50;   // Camera location..but only along the z axis
in this file
#declare Steps   =  24;      // Counter for number of steps in vignetting
'pigment'  (up to 254 )

#declare VigTex  =  texture { pigment { cylindrical
                                        color_map { #declare Rho = 0;
                                                    #while (Rho <=1)
                                                       #declare LookAng =
Rho*CamHfov/2;
                                                       #switch (VigFunc)
                                                         #case(1)  #declare
TRho = 1-Rho;                        #break
                                                         #case(2)  #declare
TRho = sqrt(0.5*(1+cos(pi*Rho)));          #break
                                                         #case(3)  #declare
TRho = pow(cos(pi/2*Rho),4);   #break
                                                       #end
                                                       #if(TRho<=0) #declare
TRho = 0;#end
                                                       [ Rho color rgb 0
transmit TRho]
                                                       #debug concat("
",str(TRho,19,6),"\n")
                                                       #declare Rho = Rho +
1/Steps;
                                                    #end
                                                  }
                                         frequency -1  rotate 90*x
                                     }
                                finish { ambient 0 diffuse 0 }
                            }

#declare VigSfr = sphere { 0,1 texture { VigTex } }
#declare BoxwitHole = intersection { box {<-1e6,-1e6,-0.1>,<1e6,1e6,0.1>}
                                     sphere { 0,1 inverse }
                                     pigment { rgb 0 } finish { ambient 0
diffuse 0 }
                                   }
#declare MicroScale = 0.001;
#declare Vignetter = union { object { BoxwitHole }
                             object { VigSfr  }
                             scale MicroScale translate
CamLocn+z*MicroScale/tan(radians(CamHfov/2))
                           }
object { Vignetter }

#declare ObjTex    = texture { pigment { rgb <1,1,0> } finish { ambient 1
diffuse 0} }

#declare VboxScale = 0.999*abs(CamLocn.z)*tan(radians(3/4*CamHfov/2));
#declare Vbox      = box{<-1,-0.005,0.01>,<1,0.005,0.02> scale VboxScale
texture { ObjTex } rotate z*90}
object { Vbox }

#declare HboxScale = 0.999*abs(CamLocn.z)*tan(radians(CamHfov/2));
#declare Hbox      = box{<-1,-0.005,-0.01>,<1,0.005,0.01> scale HboxScale
texture { ObjTex } }
object { Hbox }

#declare Ipos = -1;
#while ( Ipos<=1)
  #declare Spos = x*tan(radians(CamHfov/2*Ipos))*CamLocn.z;
  sphere { Spos,0.02*HboxScale pigment { rgb <1,1,0> } finish { ambient 1
diffuse 0 } }
  #declare Ipos = Ipos + 0.1;
#end

plane { z,1 pigment { checker color rgb 1 color rgb 0.5 translate
<1,1,0>*0.5 scale 0.2*CamHfov } finish { ambient 1 diffuse 0 } }
background { rgb 1 }

camera { #if(CamHfov >= 90) ultra_wide_angle #end
         location CamLocn up y right x*1.33  look_at 0  angle CamHfov
       }


Post a reply to this message

From: ingo
Subject: Re: More on vignetting in the camera lens
Date: 10 Feb 2003 11:36:29
Message: <Xns931EB3738DDD5seed7@povray.org>
in news:web.3e46cd6ece30e63ceb37bc10@news.povray.org Don Barron wrote:

> It now scales correctly for any camera angle and can use any
> arbitrary vignetting function.

To be honest, I didn't folow the threads on vignetting, but I wondered are 
you aware of screen.inc (7.21.3  screen.inc) and the demofile screen.pov?

Ingo


Post a reply to this message

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