Creating a ‘fisheye’ lens effect

Software: Away3D 4.x

seanClusta, Jr. Member
Posted: 10 September 2012 02:01 PM   Total Posts: 38

Hi All,
I’m hoping to render a scene using a distorted lens (a spherical ‘fisheye’ lens effect) but i’m not sure if it’s possible with the PerspectiveLens and was hoping someone could point me in the right direction to achieve this.

I think that maybe using the FreeMatrixLens and setting the projection matrix on it myself may be the way to go..?

I’m not particulrarly asking for anyone to help out with the maths to do this (although i wouldn’t turn down the solution if anyone has it wink ) but really just checking if i’m on the right track…

I know it’s possible in OpenGL to set the projection matrix to achieve this type of effect, I’m assuming it is with Away3D too but can’t find any definitive answers or examples on the subject.

Any ideas?

Thanks

   

seanClusta, Jr. Member
Posted: 10 September 2012 04:41 PM   Total Posts: 38   [ # 1 ]

I think one way of achieving this may be to adjust the Focal length of the camera/lens, combined with the lens’ fieldOfView property.

I think with a wide enough fieldOfView (say 180deg) and the right focal length it may be possible to mimic a fish eye lens. Apparently a focal length of 7.8mm would achieve similar results to looking into a convex mirror.

Now I’m not sure whether this applies in 3D software, this may be just for physical cameras but could anyone tell me how to affect the focal length of my cameras lens? It seems that (maybe due to the new rendering pipeline and the way shaders deal with rendering the viewport?) the camera no longer has .zoom and .focus properties, could anyone tell me whether these have been replaced another way of affecting this in the new version of Away3D..?

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 10 September 2012 07:45 PM   Total Posts: 669   [ # 2 ]

You might find this article interesting, if not entirely useful smile
http://strlen.com/gfxengine/fisheyequake/compare.html
Unfortunately it doesn’t work to just set a perspective lens to 180 degrees, but then I guess you already discovered that. It gives you an almost infinite distance to objects in the middle of the scene.

As for focal length, the equivalent focal length depends on view size, so it’s generally more useful to work with vertical field of view in 3D engines like Away3D.
http://paulbourke.net/miscellaneous/lens/
Setting the field of view gives the equivalent of a zoom lens zooming in and out. The camera remains stationary, but the area it projects to the screen increases and decreases.

I am hoping to build a cylindrical lens for Away3D for a 180 degree installation I’m working on. If I get anywhere with it, the approach for a fisheye would be quite similar. Hopefully someone can shed more like on this, for both of us…

Good Luck!

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 11 September 2012 10:33 AM   Total Posts: 669   [ # 3 ]

I managed a non-realtime cylindrical mapping…
http://www.videometry.net/cylinderProjection/

This uses the same technique as the original panorama film cameras, and is meant only to help understand the maths.

In contrast to a Perspective lens, it’s not just a case of applying the same transformation matrix (projection matrix) to each vertex in the scene.
Here the “vanishing point” is not a point, but a line going horizontally across the stage. So you could use a projection Matrix, but it would be different for each slice (in the cylindrical case) or each point (in the fisheye case) in the scene.

I’ll be messing more with this. Let me know if you make any progress on a realtime version.

Cheers!

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 11 September 2012 02:25 PM   Total Posts: 669   [ # 4 ]

Fisheye in da house!
http://www.videometry.net/Fisheye/
..and this time it’s realtime!

Using a similar approach to the Quake example, the effect relies on the new reflection method (thanks a million David, props!!)

This should provide a quick way to do cylindrical mapping too smile

Tutorial to follow…

 

   

Avatar
Fabrice Closier, Administrator
Posted: 11 September 2012 08:24 PM   Total Posts: 1265   [ # 5 ]

very cool!

 

   

seanClusta, Jr. Member
Posted: 12 September 2012 05:01 PM   Total Posts: 38   [ # 6 ]

Wow that’s great smile

Sorry for the late reply i have been ooo for the last 2 days and have only just got back to this.
So it is fully possible but i’m still a little oblivious to how you did it wink Did you start with the demo src from DerSchmale’s ‘Planar Reflections’ write-up? It doesn’t use a matrix transformation but instead a mirrored plane?

I haven’t looked through it fully yet, I’ll check it now- just wanted to say thanks first, this looks pretty cool

 

   

Avatar
80prozent, Sr. Member
Posted: 12 September 2012 05:26 PM   Total Posts: 430   [ # 7 ]

hi mighty atom

this looks really fantastic.
the same is true for davids reflection classes.
both are on my “how the hell they do that”-list, but i need to get some shit of my other lists done, befor i can get there.

you should expect some questions at a later time

smile

 

 Signature 

sorry…i hope my actionscript is better than my english…

   

Ivan Moreno, Newbie
Posted: 12 September 2012 05:41 PM   Total Posts: 22   [ # 8 ]

Really nice stuff mighty atom, thumbs up!

 

   

Avatar
theMightyAtom, Sr. Member
Posted: 12 September 2012 07:21 PM   Total Posts: 669   [ # 9 ]

Thanks guys. Like all good illusions, this one’s done with mirrors.
To be fair, David did all the hard work. All I did was remember a camera lens I saw once. http://www.0-360.com/optic.png
Instead of using a fish eye, it uses a normal lens pointed at a curved mirror.
In Away3D it works even better, as you don’t see the reflection of the camera smile

To achieve this effect I simply put a reflective sphere right in front of the camera, so everything you see is actually a reflection. Then all you need to remember to do is reverse your navigation…

Actually I don’t think its practically possible to make an actual fisheye that transposes vertices the way a normal perspective matrix does. For example, even a square box get’s warped in a fisheye image, and how could you do that without some serious tessellation? 
This way is probably more efficient, but don’t hesitate to prove me wrong smile

 

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X