![](/i/fill.gif) |
![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Hello!
Im trying to figure out ways to achive different types of projections.
The typical "perspective" camera in povray is known as "Gnomonical".
Apart from that there are some other projection methods I'm interested in.
Stereographic, Equidistant, Equisolid angle, and Orthograpic.
(See: https://en.wikipedia.org/wiki/Fisheye_lens)
I found Clemens Rabe's Lens Distortion patch, but I can't install it, since I
run POVRay for Windows and can not compile his code (Im not a coder).
I found some helpful macros to generate mesh-cameras by Jaime Vives Piqueres
from 2010. He implemented an example of a meshcam_lens that can uses a
distortion factor (c_distort: >0=barrel, <0=pincushion) to create a lens
distortion effect. His website where he posts his work:
(http://www.ignorancia.org/en/index.php?page=mesh-camera)
Still I don't know how he implemented the distortion, and what type of
projection it is using. Essentially he generates a mesh camera tha acts as a
regular perspective camera and then alters the vertexes (vtx_1-3) for the mesh
triangls with these formulas:
vtx_1=vtx_1-c_distort*pow(abs(vtx_1.x)*abs(vtx_1.y),2)*z;
vtx_2=vtx_2-c_distort*pow(abs(vtx_2.x)*abs(vtx_2.y),2)*z;
vtx_3=vtx_3-c_distort*pow(abs(vtx_3.x)*abs(vtx_3.y),2)*z;
c_distort is the camera distortion factor he uses in his macro.
He multiplies the absolute vertexes components of x and y and calculates the
power of 2. Then he multiplies that with z(?) and also with the distortion
factor. then he subtracts the whole thing from the original vertex
I successfully implemented the projection methods and formulas as tehy are
discribed on wikipedia (See: https://en.wikipedia.org/wiki/Fisheye_lens) within
a parametric CAD System. Now I would like to be able to render images with
povray using these exact projection methods.
Can somebody give he a hint and nudge me in the right directon as far as how i
could achive this?
The input variables for the wikipedia formulas are "f=focal length" and the
angle under which the "ray" hits the focal point. The result "r" is the distance
measured from the new point on the projection screen to the perpendicular center
from the focal point. All this is calculated of course in a 2D plane. To project
3D Points in CAD I just had to stay on this plane, rotated around the "optical
axis" So, in a sense I work with a hybrid of kartesian and polar coordinates to
get the point on the virtual CAD screen.
Anyway, any help or general thoughts on using any of these mathematical
projection methods or even real world camera formulas is welcome.
PS: It is weird that Wikipedia uses the term "Orthographic" to describe a
certain projection method for a fisheye lens, while povray usies "Orthographic"
to generate what I call a parallel projection.
Gnomonical (perspective povray camera)
Stereographic (different type of projection method)
Equidistant (different type of projection method)
Equisolid angle(different type of projection method)
Orthographic (fisheye method in wikipedia / parallel projection in povray)
Thanks in advance
Andi
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256
Le 16/10/2015 15:09, CAD-Andi a écrit :
> Can somebody give he a hint and nudge me in the right directon as
> far as how i could achive this?
>
> The input variables for the wikipedia formulas are "f=focal length"
> and the angle under which the "ray" hits the focal point. The
> result "r" is the distance measured from the new point on the
> projection screen to the perpendicular center from the focal point.
> All this is calculated of course in a 2D plane. To project 3D
> Points in CAD I just had to stay on this plane, rotated around the
> "optical axis" So, in a sense I work with a hybrid of kartesian and
> polar coordinates to get the point on the virtual CAD screen.
>
Thanks you for explaining the formula.
> Anyway, any help or general thoughts on using any of these
> mathematical projection methods or even real world camera formulas
> is welcome.
Povray has a fisheye camera,
http://wiki.povray.org/content/Reference:Camera
If I got it right from the code (tracepixel.cpp), the fisheye of
povray is wikipedia orthographic : r = f.sin(theta).
(in the code of povray, the computation is done the opposite way: you
start with r (named rad), compute theta (named phi) and use that phi
as the angle of the ray from the focal axis.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
iJsEAQEIAAYFAlYhN0sACgkQhKAm8mTpkW3MGwP4jXQxKpMH2ogRn/54tehqTBko
gQ2dGxk99dOcE9mM2oqjA10HHj/x297SdeSQRWRcy4XWavTfNdqyO5kHpe/yMDhO
dAOCiVQu+5mjyV+wajQOdPuotlrAq5QkCCTAiKuflN/3oHTPFGVrR+SCZMpvo0bQ
04tGV2DVlY2QKE4Egg==
=FDkC
-----END PGP SIGNATURE-----
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> I found some helpful macros to generate mesh-cameras by Jaime Vives
> Piqueres from 2010. He implemented an example of a meshcam_lens that
> can uses a distortion factor (c_distort: >0=barrel, <0=pincushion) to
> create a lens distortion effect. His website where he posts his
> work: (http://www.ignorancia.org/en/index.php?page=mesh-camera)
>
> Still I don't know how he implemented the distortion [...]
Well... I'm sure I did barely understand what I was doing at the time,
so now I'm really lost. Looking at it, seems just a hack by moving the
mesh vertexes along the z axis (the pow function is being used to move
them proportionally to their distance from the center of the mesh).
> Can somebody give he a hint and nudge me in the right directon as far
> as how i could achive this?
Not really, but if you're going for the mesh camera approach, you
should create a mesh that resembles the lens you are trying to simulate.
Regards,
--
jaime
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> > Still I don't know how he implemented the distortion [...]
>
> Well... I'm sure I did barely understand what I was doing at the time,
> so now I'm really lost. Looking at it, seems just a hack by moving the
> mesh vertexes along the z axis (the pow function is being used to move
> them proportionally to their distance from the center of the mesh).
Thanks for confirming the "hack" :-). I thought I was going crayz.
>
> > Can somebody give he a hint and nudge me in the right directon as far
> > as how i could achive this?
>
> Not really, but if you're going for the mesh camera approach, you
> should create a mesh that resembles the lens you are trying to simulate.
>
> Regards,
>
> --
> jaime
I never worked with mesh cameras (as you may have noticed). I'm capable to
easily create a surface in CAD that is based on the Wikipedia math formulas. I
end up with a special "lens" geometry, that is always perpendicular to the
resulting beam (For perspective projection that would be a perfect sphere).
Unfortunately, I feel like this is not helping at all, becasue I need a mesh
generated in the way that there is a triangle per pixel, right? I can't simply
export and convert my CAD "lens" and use it. Please confirm.
PS: Jaime, thanks by the way for your very interesting website. Im sure I will
return to it many times in the years to come.
Andi
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> http://wiki.povray.org/content/Reference:Camera
>
> If I got it right from the code (tracepixel.cpp), the fisheye of
> povray is wikipedia orthographic : r = f.sin(theta).
> (in the code of povray, the computation is done the opposite way: you
> start with r (named rad), compute theta (named phi) and use that phi
> as the angle of the ray from the focal axis.
>
Thanks for confirming that POVRay's fisheye is in wiki orthographic. I was
wondering what projection method was beeing used. Thanks!
Andi
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
> I never worked with mesh cameras (as you may have noticed). I'm
> capable to easily create a surface in CAD that is based on the
> Wikipedia math formulas. I end up with a special "lens" geometry,
> that is always perpendicular to the resulting beam (For perspective
> projection that would be a perfect sphere). Unfortunately, I feel
> like this is not helping at all, becasue I need a mesh generated in
> the way that there is a triangle per pixel, right? I can't simply
> export and convert my CAD "lens" and use it. Please confirm.
Not necessarily... if you make an uv-mapped mesh, you can use
distribution_type 3 with the smooth keyword, so the image resolution
it's independent of the triangle count. See meshcam_demo_uv.pov on the
examples.
Regards,
--
jaime
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Le 19/10/2015 13:29, CAD-Andi a écrit :
>
>> http://wiki.povray.org/content/Reference:Camera
>>
>> If I got it right from the code (tracepixel.cpp), the fisheye of
>> povray is wikipedia orthographic : r = f.sin(theta).
>> (in the code of povray, the computation is done the opposite way: you
>> start with r (named rad), compute theta (named phi) and use that phi
>> as the angle of the ray from the focal axis.
>>
>
> Thanks for confirming that POVRay's fisheye is in wiki orthographic. I was
> wondering what projection method was beeing used. Thanks!
>
Ok, two points, now that I analysed the povray's fisheye code.
1. It's well a wiki orthographic mapping (so I was correct on that).
2. phi in code is the rotation around the direction axis (so it is not
theta), theta is the late y0 value. (as long as you use unit vectors for
the up & right vectors of the camera, the mapping is r = F.sin(theta) )
Post a reply to this message
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
Le 21/10/2015 16:02, Le_Forgeron a écrit :
> Le 19/10/2015 13:29, CAD-Andi a écrit :
>>
>>> http://wiki.povray.org/content/Reference:Camera
>>>
>>> If I got it right from the code (tracepixel.cpp), the fisheye of
>>> povray is wikipedia orthographic : r = f.sin(theta).
>>> (in the code of povray, the computation is done the opposite way: you
>>> start with r (named rad), compute theta (named phi) and use that phi
>>> as the angle of the ray from the focal axis.
>>>
>>
>> Thanks for confirming that POVRay's fisheye is in wiki orthographic. I
>> was
>> wondering what projection method was beeing used. Thanks!
>>
>
> Ok, two points, now that I analysed the povray's fisheye code.
>
> 1. It's well a wiki orthographic mapping (so I was correct on that).
>
> 2. phi in code is the rotation around the direction axis (so it is not
> theta), theta is the late y0 value. (as long as you use unit vectors fo
r
> the up & right vectors of the camera, the mapping is r = F.sin(theta)
)
And I got dirt, mud and beers in the eyes, or behind.
The fisheye camera of povray is not orthographic, it is equidistant
( r = F.theta , as y0 (which is theta) is linear to rad. )
The fact that y0 is used later to compute the cy and sy is irrelevant,
it's just the construction of the vector in 3D.
Attached various fisheye renderings.
Post a reply to this message
Attachments:
Download 'equisolid.png' (162 KB)
Download 'fisheye.png' (158 KB)
Download 'orthographic.png' (171 KB)
Download 'stereographic.png' (151 KB)
Preview of image 'equisolid.png'
![equisolid.png](/povray.advanced-users/attachment/%3C56754a76%40news.povray.org%3E/equisolid.png?ttop=443814&toff=250&preview=1)
Preview of image 'fisheye.png'
![fisheye.png](/povray.advanced-users/attachment/%3C56754a76%40news.povray.org%3E/fisheye.png?ttop=443814&toff=250&preview=1)
Preview of image 'orthographic.png'
![orthographic.png](/povray.advanced-users/attachment/%3C56754a76%40news.povray.org%3E/orthographic.png?ttop=443814&toff=250&preview=1)
Preview of image 'stereographic.png'
![stereographic.png](/povray.advanced-users/attachment/%3C56754a76%40news.povray.org%3E/stereographic.png?ttop=443814&toff=250&preview=1)
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |
|
![](/i/fill.gif) |
| ![](/i/fill.gif) |
|
![](/i/fill.gif) |