Creating cube map images from HDR panoramas on GNU/Linux

As part of my work for Igalia I wanted to do some environment mapping. I was able to find plenty of high quality .hdr images online but I couldn’t find any (OSS) tool to convert them to cubemap images. Then, Nuclear (John Tsiombikas) gave me the solution: he wrote a minimal tool that does the job quickly and produces high quality cube maps.

So, here’s a short “how to” create cubemaps on Linux using his “cubemapper” program in combination with other OSS tools:


Install pfstools pfsview

Install the cubemapper dependencies:

1- libimago

2- libgmath

Get/Install Cubemapper:

Get the cubemapper code from here: cubemapper-0.1.tar.gz

Create the cubemaps:

Before we begin, we can check our hdr images using pfsview like that:

Sometimes the image is too big and we might need to resize it (if it’s really really big pfsview might crash).

Resize can be done by running:

(You can replace 2048 or maxy with another value)

After resizing to something more reasonable / suitable for our app, we can use the cubemapper to create the cubemap images:

With this command we should see something like that:

Pressing c will save the cubemap images in the current directory.

We can now show a cubemap made by the images we just saved, just to make sure that there aren’t any artifacts, by pressing space:

Exiting the program, we can see that the current directory contains 6 new .hdr files:

cubemap_px.hdr, cubemap_py.hdr cubemap_pz.hdr,
cubemap_nx.hdr, cubemap_ny.hdr, cubemap_nz.hdr

(one for each cubemap direction).

These 6 images can now be used as textures for cube mapping with OpenGL.

Cubemapper works also with other types of images (e.g. jpg, png).

Note: The initial .hdr panorama I used on this post is from:Β

3 thoughts on “Creating cube map images from HDR panoramas on GNU/Linux”

  1. I really tried to recreate this but I am totally lost now.
    Like – okay first of all I had to install a trillion packages, package managers, libraries etc etc etc … fine … but now when I was finally at installing the cubemapthing itself it first made me install glew … that went.. yeah I think it’s installed now – but then came glu – like not even a clue how to install that glu itself seems to have no docs… I know this post is more than a year old but I really wanted to try – maybe you can help me out or maybe by now you could offer a more compact way of installing your utility?
    Thanks for any sort of reply

    1. Sorry to hear that, the library you need is called freeglut (the package on Debian and Ubuntu based Linux distributions is called: freeglut3-dev). You can see the other dependencies in the Makefile: you need to install gph-math and libimago. The build instructions for both are on github (check the links). I hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *