POV-Ray : Newsgroups : povray.advanced-users : Simulating vignetting in a camera Server Time
25 Nov 2024 09:47:55 EST (-0500)
  Simulating vignetting in a camera (Message 1 to 10 of 11)  
Goto Latest 10 Messages Next 1 Messages >>>
From: Don Barron
Subject: Simulating vignetting in a camera
Date: 7 Feb 2003 16:20:03
Message: <web.3e4422244f26a08d3b0e910a0@news.povray.org>
Does anyone know how to simulate the vignetting that was present in old
camera lenses - a loss of brightness towards the edge of the field, say
according to a cosine law?


Post a reply to this message

From: Slime
Subject: Re: Simulating vignetting in a camera
Date: 7 Feb 2003 16:30:47
Message: <3e442587@news.povray.org>
> Does anyone know how to simulate the vignetting that was present in old
> camera lenses - a loss of brightness towards the edge of the field, say
> according to a cosine law?


Simple solution: put a sphere around the camera, textured with a cylindrical
texture (so the values you give in your color_map correspond to the cosine
of the angle), using colors of rgbf<?,?,?,1> where the ? goes from 0 at the
edges to 1 in the center.

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: hughes, b 
Subject: Re: Simulating vignetting in a camera
Date: 7 Feb 2003 22:33:41
Message: <3e447a95@news.povray.org>
"Slime" <slm### [at] slimelandcom> wrote in message
news:3e442587@news.povray.org...
> > Does anyone know how to simulate the vignetting that was present in old
> > camera lenses - a loss of brightness towards the edge of the field, say
> > according to a cosine law?
>
> Simple solution: put a sphere around the camera, textured with a
cylindrical
> texture (so the values you give in your color_map correspond to the cosine
> of the angle), using colors of rgbf<?,?,?,1> where the ? goes from 0 at
the
> edges to 1 in the center.

I'll try to expand on this and use transmit, and not filter, as the variable
and rgb 0 for the color. However, when I try the cos-4th law as I just found
it (not knowing of it before) I can't seem to get POV-Ray to produce the
same result for cos(A)^4 by using pow(cos(A),4). Am I doing that wrong? For
example, I find cos(20/2)^4 in a calculator to be
0.94060186578282644642735371998179 and yet in POV it is 0.495673773. Maybe
the order in which the operands work causing the discrepency? Although I
don't see how that could be the reason at all.

Here's the test scene I was messing with:

// my lame attempt at lens cos 4th law, not meant to be used as a totally
working concept

#declare A=67; // angle
#declare R=<10,0,0>; // orientation
#declare L=<0,0,-5>; // location
#declare V=20; // variable, degrees? divided in half later

camera {
  location  0
  look_at   z
  angle A
  rotate R
  translate L
}

sphere {
  0, 1
  texture {
    pigment {
      cylindrical
      color_map {
        [0 color rgb 0 transmit 1 ]
        [pow(cos(V/2),4) color rgb 0 transmit pow(cos(V/2),4) ]
        [1 color rgb 0 transmit 0 ]
      } frequency -1 rotate 90*x
    }
    finish{
      ambient 0 diffuse 0
    }
  }
  scale 0.0001 // make small/invisible
  rotate R
  translate L
}

#debug concat(str(pow(cos(V/2),4),-1,9))

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0 rgb <0.7,0.8,0.9>]
      [1 rgb <0.2,0.5,0.8>]
    }
  }
}

light_source {
 <-30, 30, -30>,1
}

// ----------------------------------------

plane {
  y, -1
 pigment {color rgb 1}
}

sphere {
  0.0, 1
 pigment {color rgb 1}
}


Post a reply to this message

From: Slime
Subject: Re: Simulating vignetting in a camera
Date: 7 Feb 2003 22:48:41
Message: <3e447e19$1@news.povray.org>
> example, I find cos(20/2)^4 in a calculator to be
> 0.94060186578282644642735371998179 and yet in POV it is 0.495673773.

You're using degrees on your calculator and radians in POV. To convert from
degrees to radians, multiply by pi/180.

 - Slime
[ http://www.slimeland.com/ ]


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Simulating vignetting in a camera
Date: 7 Feb 2003 23:05:02
Message: <web.3e44810368f85955b417814a0@news.povray.org>
hughes, b. wrote:
>... I can't seem to get POV-Ray to produce the
>same result for cos(A)^4 by using pow(cos(A),4). Am I doing that wrong? For
>example, I find cos(20/2)^4 in a calculator to be
>0.94060186578282644642735371998179 and yet in POV it is 0.495673773. Maybe
>the order in which the operands work causing the discrepency? Although I
>don't see how that could be the reason at all.
>...

Bob, POV-Ray uses radians while your calculator uses
degrees. You can write the expression like this:

pow(cos(radians(20/2)), 4)

- if you want POV-Ray to give the same results as
your calculator.

(Or you can set your calculator to radians mode.
If it is a Casio, then you can probably do this
by pressing MODE and then 5)

If you want to use the acos function in POV-Ray
and want to have the result in degrees, then you
can just write:

degrees(acos(0.5))


Tor Olav


Post a reply to this message

From: hughes, b 
Subject: Re: Simulating vignetting in a camera
Date: 8 Feb 2003 00:48:59
Message: <3e449a4b@news.povray.org>
I was beginning to try degrees in that before posting before and quit since
I wasn't seeing anything right still. Turns out I had to go with radians to
equal the same result for degrees in the MS "PowerToys" calculator I needed
to use because my Casio calculator needs batteries again. Nice to see I
wasn't on the wrong path by thinking it was to do with degrees, but this
calc was originally set to radians and I wasn't getting results right with
it either until I changed to degrees. Mental block prevented me from trying
radians in POV-Ray. Just needed degrees and that wasn't happening right.
Funny I couldn't figure this out at the time, but it's because I don't keep
in mind how POV deals with such things.

I wanted to find out about this idea so I'm glad I had help and the
incentive from Don Barron. Now I'm wondering if the sphere is the ideal
object or if it should be a disc... but then where to position it? Guess I'm
not going to want to know this for perfection of the concept, maybe Don
might though. Anyway, again:

/* cos 4th power law of lens light falloff. Thanks guys: Tor Olav
Kristensen, and Slime */

#declare A=67; // angle
#declare R=<10,0,0>; // orientation
#declare L=<0,0,-5>; // location
#declare V=A; // variable, degrees? probably still not true to the real
world(?)

camera {
  location  0
  look_at   z
  angle A
  rotate R
  translate L
}

/* okay, so it's cosine of radians of the angle apparently, or whatever.
yea! */
sphere {
  0, 1
  texture {
    pigment {
      cylindrical
      color_map {
        [0 color rgb 0 transmit 1 ]
        [pow(cos(radians(V/2)),4) color rgb 0 transmit
pow(cos(radians(V/2)),4) ]
        [1 color rgb 0 transmit 0 ]
      } frequency -1 rotate 90*x
    }
    finish{
      ambient 0 diffuse 0
    }
  }
  scale 0.0001 // make small/invisible
  rotate R
  translate L
}

/* now if I just knew any better way to blend-map that, if can be */

#debug concat("\n cos 4th law: value for ",str(V,0,0)," degrees is
",str(pow(cos(radians(V/2)),4),-1,9),"\n")

// ----------------------------------------

sky_sphere {
  pigment {
    gradient y
    color_map {
      [0 rgb <0.7,0.8,0.9>]
      [1 rgb <0.2,0.5,0.8>]
    }
  }
}

light_source {
 <-30, 30, -30>,1
}

plane {
  y, -1
 pigment {color rgb 1}
}

sphere {
  0.0, 1
 pigment {color rgb 1}
}


Post a reply to this message

From: Don Barron
Subject: Re: Simulating vignetting in a camera
Date: 8 Feb 2003 09:00:05
Message: <web.3e450d2668f85955106a08510@news.povray.org>
Don Barron wrote:
>Does anyone know how to simulate the vignetting that was present in old
>camera lenses - a loss of brightness towards the edge of the field, say
>according to a cosine law?
> Thanks for those so-prompt suggestions


Post a reply to this message

From: Don Barron
Subject: Re: Simulating vignetting in a camera
Date: 8 Feb 2003 11:50:03
Message: <web.3e45349d68f859559515830d0@news.povray.org>
Don Barron wrote:
>Does anyone know how to simulate the vignetting that was present in old
>camera lenses - a loss of brightness towards the edge of the field, say
>according to a cosine law?
>/* Simulating vignetting in the camera lens.
   Just a comment...   it's vignetting in the lens design and fabrication
which early lenses
   had, to reduce the serious image aberrations from the primitive lenses of
the time.
   ..the cos^4 effect is something else, but all the same...

   thanks to SLIME for the suggestion of a textured microscopic sphere
enclosing the
   camera.  This is his pov file but with a while loop inside
   the pigment color_map and a similar color_map applied to his object
sphere. Nice one...
*/

#declare A=67;       // angle
#declare R=<10,0,0>; // orientation
#declare L=<0,0,-5>; // location
#declare V=A; // variable, degrees? probably still not true to the real
world(?)

camera {location 0 look_at z angle 1.3*A rotate R    translate L   }


sphere { 0,1 pigment { cylindrical color_map { #declare Rho = 0;
                                                    #while (Rho <=1)
                                                         #declare TRho =
pow(cos(pi/2*Rho),4);
                                                        [ Rho color rgb 0
transmit TRho]
                                                        #debug concat("
",str(TRho,9,3),"\n")
                                                        #declare Rho = Rho +
0.1;
                                                    #end
                                             }
                       frequency -1 rotate 90*x
                     }
               finish{ ambient 0 diffuse 0 }
               scale 0.0001
               rotate R translate L
       }

sphere { 0,1 pigment { cylindrical color_map { #declare Rho = 0; #declare
Steps = 12;
                                               #while (Rho <=1)
                                                   #declare TRho =
pow(cos(pi/2*Rho),1);
                                                   [ Rho color rgb 0
transmit TRho]
                                                   #declare Rho = Rho +
1/Steps;
                                                   #end
                                             }
                       frequency -1 rotate 90*x
                     }
               finish{ ambient 0 diffuse 0 }
         rotate y*15 rotate -x*25
       }


sky_sphere { pigment { gradient y  color_map { [0 rgb <0.7,0.8,0.9>]
                                               [1 rgb <0.2,0.5,0.8>]
                                             }
                     }
           }

light_source { <-30, 30, -30>,1 }
plane { y,-1  pigment {color rgb 1} }


Post a reply to this message

From: Don Barron
Subject: Re: Simulating vignetting in a camera
Date: 8 Feb 2003 17:55:03
Message: <web.3e458a2e68f85955299143b00@news.povray.org>
hughes, b. wrote:
>"Slime" <slm### [at] slimelandcom> wrote in message
>news:3e442587[at]news.povray.org...
>> > Does anyone know how to simulate the vignetting that was present in old
>> > camera lenses - a loss of brightness towards the edge of the field, say
>> > according to a cosine law?
>>
>> Simple solution: put a sphere around the camera, textured with a
>cylindrical
>> texture (so the values you give in your color_map correspond to the cosine
>> of the angle), using colors of rgbf<?,?,?,1> where the ? goes from 0 at
>the
>> edges to 1 in the center.
>
>I'll try to expand on this and use transmit, and not filter, as the variable
>and rgb 0 for the color. However, when I try the cos-4th law as I just found
>it (not knowing of it before) I can't seem to get POV-Ray to produce the
>same result for cos(A)^4 by using pow(cos(A),4). Am I doing that wrong? For
>example, I find cos(20/2)^4 in a calculator to be
>0.94060186578282644642735371998179 and yet in POV it is 0.495673773. Maybe
>the order in which the operands work causing the discrepency? Although I
>don't see how that could be the reason at all.
>
>Here's the test scene I was messing with:
>
>// my lame attempt at lens cos 4th law, not meant to be used as a totally
>working concept
>
>#declare A=67; // angle
>#declare R=<10,0,0>; // orientation
>#declare L=<0,0,-5>; // location
>#declare V=20; // variable, degrees? divided in half later
>
>camera {
>  location  0
>  look_at   z
>  angle A
>  rotate R
>  translate L
>}
>
>sphere {
>  0, 1
>  texture {
>    pigment {
>      cylindrical
>      color_map {
>        [0 color rgb 0 transmit 1 ]
>        [pow(cos(V/2),4) color rgb 0 transmit pow(cos(V/2),4) ]
>        [1 color rgb 0 transmit 0 ]
>      } frequency -1 rotate 90*x
>    }
>    finish{
>      ambient 0 diffuse 0
>    }
>  }
>  scale 0.0001 // make small/invisible
>  rotate R
>  translate L
>}
>
>#debug concat(str(pow(cos(V/2),4),-1,9))
>
>sky_sphere {
>  pigment {
>    gradient y
>    color_map {
>      [0 rgb <0.7,0.8,0.9>]
>      [1 rgb <0.2,0.5,0.8>]
>    }
>  }
>}
>
>light_source {
> <-30, 30, -30>,1
>}
>
>// ----------------------------------------
>
>plane {
>  y, -1
> pigment {color rgb 1}
>}
>
>sphere {
>  0.0, 1
> pigment {color rgb 1}
>}
>
Dear Mr.Hughes,

Rereading the missages I see that I have incorrectly attributed to SLIME
himself  the pov file elaborating SLIME's suggestion concerning a solution
to the question.  Please accept my apologies - and I hope you enjoyed my
modest extension to your elegant solution.

I find it strange that the messages are printed in reverse order - I expect
to see the latest at the top of the list...anyway, thanks again.

Yours,

Don Barron


Post a reply to this message

From: hughes, b 
Subject: Re: Simulating vignetting in a camera
Date: 8 Feb 2003 19:29:29
Message: <3e45a0e9@news.povray.org>
"Don Barron" <ani### [at] ukonlinecouk> wrote in message
news:web.3e458a2e68f85955299143b00@news.povray.org...
> Dear Mr.Hughes,
>
> Rereading the missages I see that I have incorrectly attributed to SLIME
> himself  the pov file elaborating SLIME's suggestion concerning a solution
> to the question.  Please accept my apologies - and I hope you enjoyed my
> modest extension to your elegant solution.
>
> I find it strange that the messages are printed in reverse order - I
expect
> to see the latest at the top of the list...anyway, thanks again.

And Mr. Barron... or Don if I may, I wasn't going to mention it. Doesn't
matter to me. It started off as yours and his ideas anyhow. Tor also led me
in the right direction.

I went looking a tiny bit further into this and now I'm confused why I
managed to get the correct result by putting radians() inside the cos(). I
only made it through Algebra III in school, which doesn't help me here.
POV-Ray supposedly does the cosine in radians already, so when I first tried
degrees() and didn't get the right answer that made me think I was doing it
all wrong. Using it outside of cos() is of no use either, apparently. Maybe
acos() is okay, as Tor suggested but I never tried that. So I'm puzzled as
to how the radians of a float is acted upon by the cos() function.

Well, that aside, I tried what you changed it all too so I could see what
you were making of it. Seems to me there needs to be a way to cause the
fall-off to--- well, fall off at a certain rate dependant on the amount of
angle as it changes through the color map. Of course, I noticed you said you
weren't trying for the actual fall off of light per the cos 4th law but
instead wanting to mimic some kind of vignetting due to obstruction that is
part of a lens. At least I think you said that.

If anybody thinks cos(radians()) = degrees is peculiar I'm all ears. I'll
have learned something.

--
Farewell,
Bob


Post a reply to this message

Goto Latest 10 Messages Next 1 Messages >>>

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