An application for Mac to compute Spherical Harmonics from pictures.



Harmonikr

A tool to compute the spherical harmonics of an environment map.

Features:

  • Support for HDR images, both for import and export.
  • Compute any arbitrary number of harmonics.
  • Compute irradiance.
  • Store harmonics or irradiance as a 2D map, for fast sampling in a custom shader.
  • Import side-cross cubemaps, or individual faces, and export side-cross cubemaps.
  • Import equirectangular maps.
  • Rotate cubemaps.
  • Save project files, containing images and settings per project.

Usage

Main window

When you start a new project, you will see a new window with these elements (from top to bottom):
  • A toolbar
  • A Sphere Map, which is a 2D map representing the spherical harmonics, and a cubemap next to it.
  • A place to drag & drop images at the middle, in the shape of a side-cross cubemap.
  • An area at the bottom where you can either see the list of spherical harmonics, or the settings of your project.
These are the list of settings:

Importing images

To create a new environment map, drag images to the central area, which represents a cubemap: -X, +Z, +X, -Z, for the central row, and +Y, and -Y for the top and bottom, respectively. See visual guide below:

At the moment, you can

  • Set 6 pictures, one per face. They will just be interpreted as the 6 faces of a cubemap. The resulting cubemap is shown at the top of the project and the faces are displayed in this order: +X, -X, +Y, -Y, -Z, +Z. See screenshot above.
  • Set 4 pictures (top, bottom, 1st and 3rd from the middle row). The pictures at the central row will be stretched.
  • Set just one picture, at the left-most image well (labelled -X above). The image will be interpreted as an equirectangular map. See example at the top of this document. But if you also place an image at -Y, the ground of the environment map will be replaced with the face you pasted there.
After dragging all the images you need, click on the Infer button to generate a cubemap from those pictures. The cubemap should appear at the top.

Alternatively, go to the menu and select File → Import Side-Cross Cubemap to import a side-cross cubemap.

Harmonikr supports 8-bit, 16-bit, and 32-bit images. 32-bit images are always imported as float, and it is important that you select HDR32 as the Output precision in the Settings screen. Images with extension .hdr fall in this category.

32-bit images are exported as .hdr. You can select PNG as an output as well, but then colors will be clamped to 16-bit integer values.

If you want to clamp your images to 8 bits per channel, you can select LDR as Output precision, but 32-bit images will look almost black because the program does not auto-scale the values.

Compute spherical harmonics

Once you have a cubemap, click on Compute to compute the Spherical Harmonics coefficients for the given cubemap. Notice how the Sphere Map next to the cubemap changes when done.

You can compute the Irradiance once you have computed the Spherical Harmonics. Just click on the Irradiance button. The Sphere Map will be updated again.

You can export the Sphere Map as a PNG image file, or as an HDR file for 32-bit output precision.

Save project

You can also save the project to an .spharm file. The file contains all the images you pasted, and the settings you may have configured.

Settings

Through the Settings tab you can:
  • increase/decrease the number of bands/coefficients for the Spherical Harmonics,
  • increase/decrease the number of samples (jittered stratification over a sphere) used when computing them,
  • set the area used to represent the positive hemisphere in the Sphere Map. The center of the Sphere Map is the positive hemisphere, whereas the rest represent the negative side. This parameter is the radius of the positive size.
  • increase/decrease the resolution of the Sphere Map,
  • increase/decrease the resolution of the cubemap,
  • change the color precision of the environment map: LDR (8 bits per channel), HDR16 (16 bits per channel, integer), HDR32 (32 bits per channel, float; for .hdr images);
  • apply a global scale to the values (in linear RGB),
  • rotate the cubemap along the vertical axis (Y). See below an example illustrating the result of rotating a cubemap.

Note that by default, when using LDR images, a conversion to linear RGB is applied internally (since light is linear! so we undo the gamma correction). However, for HDR formats colors should be linear already.


Debugging fun


News