Spectrum Bands - RenderToolbox/RenderToolbox4 GitHub Wiki

RenderToolbox uses renderers that render in multi-spectra (wavelength-by-wavelength) fashion. This improves rendering accuracy and allows users to specify multi-spectral reflectances and illuminant spectra, but requires a little bookkeeping to keep track of spectrum bands.

This page describes spectrum bands as seen from renderers, RenderToolbox, and the Psychophysics toolbox.

Renderers

The renderers PBRT and Mitsuba must be built from source in order to use sampled spectra. We make pre-built renderers available via Docker.

Note that spectrum values specified at renderer build time refer to spectrum band edges. So 395nm is the low edge of the first band, and 705nm is the high edge the last band. This gives each band a width of 10nm.

Each renderer outputs images with multiple color channels, one for each spectrum band. Mitsuba saves a band description along with each color channel, so RenderToolbox is able to read band descriptions along with image data. pbrt-v2-spectral doesn't save band descriptions, so RenderToolbox keeps track of PBRT spectrum bands using a different mechanism (see Determining "S", below).

Band Edges vs. Centers

Unlike the renderers, RenderToolbox describes spectrum bands using band centers. This allows RenderToolbox to use lots of colorimetric tools from Psychtoolbox.

Specifically, RenderToolbox uses the Psychtoolbox "S" format, which is a compact description of the spectrum bands in an image. It is matrix with 3 elements:

S = [start delta n]

where start is the center of the lowest band, delta is the width of each band, and n is the total number of bands. start and delta are wavelengths in nanometers.

The RenderToolbox pre-built renderers use an "S" description like this:

S = [400 10 31]

with the start value falling half way along the first spectrum band, at 395nm + 10nm/2 = 400nm.

Determining "S"

For Mitsuba, RenderToolbox determines the "S" of each multi-sprectral image by reading band descriptions saved in the image file. The rtbReadMultispectralEXR() function returns an "S" along with multi-spectral image data.

For PBRT, RenderToolbox always uses the same "S". The rtbLocalConfigTemplate() function stores a default "S", which can be accessed later with Matlab's built-in getpref() and setpref() functions. Try:

S = getpref('PBRT', 'S')

Using a Different "S"

You might want to build the renderers with a different spectrum sampling. For example, the official Mitsuba distribution samples the spectrum in the range 368-830nm. If you build PBRT to use this range, you must tell RenderToolbox about your new "S".

The range 368-830nm spans 462mn. If you sampled it with 77 bands, the width of each band would be 6nm. The first band center would fall half way along the first band, at 368nm + 3nm = 371nm. So the "S" description for this sampling would be:

S = [371 6 77]

You would need to tell RenderToolbox about this "S", using setpref():

S = [371 6 77];
setpref('PBRT', 'S', S);

Wavelength Bands vs. Unit Wavelengths

RenderToolbox interprets spectral power distributions as having units of Power per Unit Wavelength. In RadianceTest, we determined that Mitsuba and PBRT obey the same convention.

Psychtoolbox colorimetric functions use a different convention, interpreting spectral power distributions as having units of Power per Wavelength Band.

In order for RenderToolbox to make use of Psychtoolbox colorimetric functions, it must keep track of the different conventions:

  • When getting spectral power distributions from Psychtoolbox, RenderTooblox3 uses the functions ImportPsychColorimetricMatFile() and rtbSpdPowerPerWlBandToPowerPerNm().
  • When sending spectral power distributions to Psychtoolbox, RenderTooblox3 uses the function rtbSpdPowerPerNmToPowerPerWlBand().

These functions scale spectral power distributions up or down, by the width of a spectrum band, in order to accommodate one convention or the other.

When invoking RenderToolbox functions, users should always assume that spectral power distributions are in units of Power per Unit Wavelength. Users should not need to worry about Power per Wavelength Band, unless invoking Psychtoolbox colorimetric functions directly.