Fisheye projection matrix in Xna/OpenGL - 3D
Asked Answered
H

3

5

I'm looking for a projection matrix I can use in 3D that will give me the effect of a fisheye. I'm not looking for a pixelshader or anything like that, that will manipulate pixels - but the actual projection matrix used in projecting from 3D space onto 2D.

Thanks.

Henricks answered 17/7, 2010 at 20:41 Comment(2)
this could be handy: local.wasp.uwa.edu.au/~pbourke/miscellaneous/domefisheye/…Brian
Thanks. That will come handy in other scenarios I'm looking at.Henricks
C
3

Carlos isn't wrong but you might want to try playing with the "field of view (FOV)" parameter in your projection matrix builder.

Connacht answered 21/7, 2010 at 8:1 Comment(2)
Thanks both. I guess I'll need to look over my Matrix calculations - my first guess was also to experiment with FOV, but didn't get the desired effect. I'm looking at more of an approximation, rather than pixelperfect.Henricks
@Einar, As Goz said Carlos is on the money - FOV works for the endpoints, transforms them where they are supposed to be, but it still draws the straight line between them. Try to create a few meshes that represent a triangle - using a single polygon or using 10 polygons and using 1000 polygons. Then try to play with FOV, maybe things are going to be more clear.Ulphiah
G
13

That's not really possible. In homogeneous coordinates, matrices transform lines to lines. So any solution based solely on matrices will necessarily fail to bend lines like you want to.

Galengalena answered 17/7, 2010 at 22:52 Comment(0)
C
3

Carlos isn't wrong but you might want to try playing with the "field of view (FOV)" parameter in your projection matrix builder.

Connacht answered 21/7, 2010 at 8:1 Comment(2)
Thanks both. I guess I'll need to look over my Matrix calculations - my first guess was also to experiment with FOV, but didn't get the desired effect. I'm looking at more of an approximation, rather than pixelperfect.Henricks
@Einar, As Goz said Carlos is on the money - FOV works for the endpoints, transforms them where they are supposed to be, but it still draws the straight line between them. Try to create a few meshes that represent a triangle - using a single polygon or using 10 polygons and using 1000 polygons. Then try to play with FOV, maybe things are going to be more clear.Ulphiah
S
0

Carlos is right. There is a way your could fake it, but you will have to re-render your scene multiple times.

Basically, you start by figuring out how to do two point perspective. Which I would do by rendering the scene twice with a projection matrix that has a vanishing point on alternating sides. Then you combine the two parts, I guess using a stencil map.

You could do something like four point perspective combining images with four vanishing points. You repeat that process as many times.

What your doing then is projecting onto a polygon that approximates a sphere.

I could explain more, but my guess is it sounds too complicated.

The simplest way to fake it is to render to a texture and distort the image, and render it as a fullscreen quad.

Sanitation answered 23/7, 2010 at 22:19 Comment(1)
Thanks for the input - great idea. My problem was related to something that made me blush when I saw it. I had an error when projecting to the screen, which caused all my efforts in changing FOV to get the effect I wanted useless.Henricks

© 2022 - 2024 — McMap. All rights reserved.