|
|
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.
2. What is the Z parameter there for? Is it needed for the normal?
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.
Thanks,
Bill
PS: I have tried to find this info in the help, but couldn't.
// lens distortion model
// i' = i + a * i * sqrt(i^2 + j^2) + b * i^3 * sqrt(i^2 + j^2)
// j' = j + a * j * sqrt(i^2 + j^2) + b * j^3 * sqrt(i^2 + j^2)
// lens distortion implementation
#declare lens_dist = function(x, y, z, a, b) {
(x + a * x * sqrt(x*x + y*y) + b * x^3 * sqrt(x*x + y*y) ) ^ 2 +
(y + a * y * sqrt(x*x + y*y) + b * y^3 * sqrt(x*x + y*y) ) ^ 2
}
#declare a_factor = 0.65;
#declare b_factor = 0.1;
#declare HFOV = 5.00;
#declare VFOV = HFOV * 3 / 4;
#declare cameraheight = 10.000;
camera {
orthographic
location <0, 0, 0>
right <HFOV, 0, 0>
up <0, VFOV, 0>
sky <0, 1, 0>
direction <0, 0, cameraheight>
look_at <0, 0, 1>
translate <0, 0, -cameraheight>
normal{function {lens_dist(x, y, z, a_factor, b_factor)} }
}
#local mx = 9;
#local my = 7;
#local ix = 0;
#while(ix < mx)
#local iy = 0;
#while(iy < my)
cylinder {
<0,0,0>, <0,0,0.010>, 0.25
pigment {color rgb <0, 0, 0>}
translate <(ix - ((mx - 1) / 2))* 0.8, (iy - ((my - 1) / 2))* 0.8, 0>
}
#local iy = iy + 1;
#end
#local ix = ix + 1;
#end
Post a reply to this message
|
|