POV-Ray : Newsgroups : povray.general : simulating lens distortion with normal and function in 3.5 : Re: simulating lens distortion with normal and function in 3.5 Server Time
19 Nov 2024 13:44:47 EST (-0500)
  Re: simulating lens distortion with normal and function in 3.5  
From: Bill Brehm
Date: 25 Feb 2002 18:12:25
Message: <3c7ac4d9$1@news.povray.org>
Thanks Mike.

1. Where does the 0.016 for Z come from? Is that a constant built into
POVRay? Do X and Y both vary from -0.5 to +0.5, even though the camera is
rectangular (3/4)? Then I need to consider the camera's aspect ratio in my
function, right?

2. When would I want to use Z, if it is a constant? Do one or more of the
camera types have a variable Z? Is it useful when the camera is translated
in some way?

3. POVRay help shows an diagram explaining the perspective camera. The rays
emanate from "location", pass through the image plane, then eventually hit
an object. Those rays are not normal to the plane, except at the center. For
the orthographic camera, one could consider that "location" is infinitely
far away, so that the rays are normal to the image plane. Or one could
consider that the rays emanate from the image plane itself normal to the
plane.

I'm I correct so far? Assuming yes,

Can I imagine that the normal function distorts the image plane into a shape
determined by the scalar field and that the rays emanate from that distorted
image "plane" normal to the "plane" at that point? Is that still true for a
perspective camera with a normal applied to it? I.e., should I sort of
forget about "location" and think of a perspective camera as having an image
plane distorted into a piece of a sphere having the rays emanate normal to
that distorted image "plane"? Couldn't  I then simulate any camera type with
the proper normal function?

How does POVRay actually determine the normal at each point? Does it use the
derivative of the function to calculate it exactly or does it look at the
surrounding points and calculate a rough approximation? (I'm trying to
generate "perfect" images with a known amount of lens distortion to test a
correction algorithm.)

Thanks again,

Bill


"Mike Williams" <mik### [at] nospamplease> wrote in message
news:78E### [at] econymdemoncouk...
> Wasn't it Bill Brehm who wrote:
> >Hi,
> >
> >I've asked before about simulating lens distortion. I got some helpful
> >pointers, but I'm stuck again.
> >
> >A mathematician working at another company came up with the following
> >additions to my camera definition and sent it to me. But I cannot reach
him
> >now, so I'm hoping someone here can help me understand.
> >
> >The distortion has the correct form, i.e., a square is distorted to the
> >correct shape. But the image is also magnified and I need to control that
> >too. Even when I set the factors to zero, there is magnification.
> >
> >So my questions are:
> >
> >1. What does lens_dist() return? A float? A vector? I think it's
returning a
> >single float value based on the X, Y coordinates passed in.
>
> It's returning a float value for every point in space. For this particular
set
> of camera parameters, the camera behaves as if it is a flat plate with z
> parameter about -0.016, and with the x and y parameters varying
between -0.5 and
> +0.5 across and up the image.
>
> E.g. at the centre of the image, the virtual camera point is about
<0,0,-0.16>,
> and the lens_dist(x,y,z,0.65,0.1) function returns a value of 0 at that
point.
> At the corner, the virtual camera point is <0.5,0.5,-0.16> and the
> lens_dist(x,y,z,0.65,0.1) function returns a value of 1.09120 at that
point. I
> calculated that with a math package, and then also obtained it from POV by
> typing
>         debug str( lens_dist(0.5,0.5,-0.16,a_factor,b_factor) ,5,5)
> and looking at the message pane.
>
> >2. What is the Z parameter there for? Is it needed for the normal?
>
> No. You get exactly the same result if you declare the lens_dist()
function as
>         #declare lens_dist = function(x, y, a, b) { ...
> instead of
>         #declare lens_dist = function(x, y, z, a, b) { ...
> and invoke it as
>         normal{function {lens_dist(x, y, a_factor, b_factor)} }
> You just have to be sure that you then don't change the function so that
it uses
> Z.
>
> >3. How exactly does a normal work when applied to a camera to distort
> >the image? What is a normal? Is it a function or pattern that has one
value for
> >each X, Y coordinate? How does that bend the ray? Is there any diagram
that
> >shows how it works? I would think that a normal would need two values at
> >each coordinate, so it knows how much and in which direction to bend the
> >ray.
>
> In physics, a "normal" is a vector perpendicular to the surface of an
object at
> a particular point.
>
> In POV, we often fake the normals of objects to give the appearance of the
> actual object having a certain surface structure. When a ray strikes the
object,
> the ray is reflected and refracted as if it had struck the object at a
different
> angle.
>
> POV also represents what you might expect to be a vector field (having a
> magnitude and direction at every point) with a scalar field (having only a
> single float value for each point in 3d space). It's as if the surface
gets
> "raised" by the specified value, and the actual normal is the tangent
plane to
> the resulting surface. For the vast majority of cases, such a
representation is
> very much easier for users to handle - specifying the magnitude and
direction of
> the normal at every point would be unnecessarily tedious in most scenes.
>


Post a reply to this message

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