views:

99

answers:

3

Hi, 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.

+3  A: 

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.

Carlos Scheidegger
+1  A: 

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

Goz
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.
Einar Ingebrigtsen
A: 

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.

Jonathan Fischoff
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.
Einar Ingebrigtsen