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

git clone
sudo make install

2- libgmath

git clone
sudo make install

Get/Install Cubemapper:

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

tar xzvf cubemapper-0.1.tar.gz
cd cubemapper-01/
sudo make install

Create the cubemaps:

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

pfsin foobar_in.hdr | pfsview

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:

 pfsin foobar_in.hdr | pfssize --maxy 2048 | pfsout foobar_out.hdr

(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:

cubemapper foobar_out.hdr

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:

Creating cube map images from HDR panoramas on GNU/Linux

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s