I'd like to transform a sequence of circular fisheye-images to cubic or spherical panorama images to be used in a panorama-viewer based on OpenGL. The viewer-part is nemas problemas but the transform from fisheye to panorama is not my usual cup of tea. I was kind of expecting a google would solve this, but so far I have come up with next to nothing. What would the preferred method be? OpenGL or pixelshaders?

The image sequence is coming from a camera so it has to be done in realtime (or as fast as possible). I have used PanoTools for Photoshop before so I know a little about the process, but not much about the math behind. Any kind soul out there who could get me started? Any resources that could be useful? This can't be something new but I guess it's not that common either. Anyway it's a fun project ... =)


Found this awesome online shader-laboratory: https://www.shadertoy.com

Just too bad I can't add my own image-inputs here...


2 Answers 2


Since you're going to have a real-time panorama viewer anyway, it seems to me you could configure your panorama viewer to view the fisheye images directly. There is no need to convert them to a cubemap or lat-long format first.

A panorama viewer works by drawing a mesh of some shape (e.g. a cube or sphere) around the camera, and setting up texture coordinates on the mesh such that the image gets wrapped around the mesh in the same mapping used to generate the original image. So viewing fisheye images with it is just a matter of coding up the right mapping. I would suggest building a reasonably tessellated hemisphere and mapping spherical coordinates on the hemisphere to polar coordinates around the center of the 2D fisheye image. No pixel shaders will be needed, just standard texture mapping.

You will need the right mapping between the radial coordinate of the fisheye image and the polar angle of the sphere. Unfortunately, there is no standard fisheye mapping - there are several variations that are all called "fisheye". Wikipedia describes some. The docs for your lens might say what kind of mapping it uses, or you might just have to experiment a bit until things look right.

  • \$\begingroup\$ You wouldn't render to a mesh. You'd just render a quad and make your shader do the lookup from fisheye image to the view. \$\endgroup\$
    – gman
    Mar 22, 2020 at 12:41

The image you provided even simplifies the whole thing.

What you are looking for is called polar to rectangular coordinates transformation. It's very simple.

You can find some reference here : http://www.cliffsnotes.com/study_guide/Polar-Coordinates.topicArticleId-11658,articleId-11630.html

No point in me going over the topic again as it's avaialable everywhere :)


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .