|
|
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
|
|