Reputation: 239
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.
Upvotes: 5
Views: 4608
Reputation: 1487
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.
Upvotes: 0
Reputation: 62333
Carlos isn't wrong but you might want to try playing with the "field of view (FOV)" parameter in your projection matrix builder.
Upvotes: 3
Reputation: 1966
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.
Upvotes: 13