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:

Leave a Reply

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