Light Map Gen
Jeremy Pronk 2005
www.happiestdays.com
Version 1.0beta4
Whats New
1.0beta4
- Increased precision in light map files
- Outputs sample solid angle (spherical area) to the light file map
(current only implemented for Median Cut)
- New normalize technique, set total light map intensity to 1 (old
technique is called -normalize2)
- Runtime speed increased due to new compiler optimizations (Win32
version)
- Linux version (x86)
1.0beta3
- Added median cut sampling. Based on
ideas in the sketch "A Median Cut Algorithm for Light Probe Sampling"
by Paul Debevec.
- Added "resize" parameter.
- Added lightMapGen_loader MEL script
1.0beta2
Overview
lightMapGen is a small application designed to find the most
appropriate sample locations in an intensity map.
See quick start.
For specific details on the techniques employed it is essential one
reads the following papers
- A
Median Cut Algorithm for Light Probe Sampling by Paul Debevec
-
Efficient illumination by high
dynamic
range images by Thomas Kollig and Alexander Keller.
- Interleaved
Sampling by Alexander Keller and Wolfgang Heidrich
Usage
The command line program "lightMapGen" accepts a single high dynamic
range floating-point TIFF image and a number of parameters. The common
use of lightMapGen is to generate a light map from a latlong HDR Tiff
image which can then be used directly by sphericalLight to illuminate
geometry in mental ray.
lightMapGen may also be useful for those interested in utilizing the
light map file in their own light shader. Hopefully the file format is
self explanatory.
See quick start.
Light Map Gen Loader
lightMapGen_loader is a simple Maya MEL script which will load a
lightMapGen light map as a "dome" of lights. There are simple controls
for all the lights in the transform of the parent locator.
What is Interleaving Sampling?
Interleaved sampling is an idea which was central to the creation of
lightMapGen. Please see Interleaving Sampling,
Alexander Keller and Wolfgang Heidrich for a thorough explanation.
The basic idea is to render with the same number of light samples but
to choose alternating (light) sample locations actually calculated from
the map itself. This provides for much improved anti-aliasing
particularly in the shadowed (or occluded) parts of the render.
Parameters
Required Arguments
Input map (-in filename)
Input intensity map. Must be a valid floating-point
TIFF file.
Sample number (-s N M)
N is the number of samples to calculate
M is only used for sampling type 3 & 4 and is the number of
interleave levels for each sample. If M is specified interleaved sample
generation is invoked.
Optional Arguments
Sampling type (-st sampling-type)
0 - voronoi tessellation (used for debugging)
1 - centroidal voronoi tessellation (CVT), similar to technique used in
lightGen
2 - importance voronoi tessellation, much improved variation on CVT
3 - interleaved importance voronoi tessellation, as 2 with multiple
interleave levels for each sample
4 - median cut (default)
Map type (-mt map-type)
Format of input intensity map.
0 - flat map
1 - lat-long or spherical map, must have an aspect ratio of 2:1
(default)
2 - test map, for debugging
Resize (-resize amount)
Resizes the input image amount times before processing. Good for up
sizing small maps when using median cut and for downsizing large maps
we using voronoi style sampling. (defaults to 1.0)
Normalize (-normalize)
When specified, the samples will be scaled so the total intensity is 1
(i.e. all samples add up to 1)
Normalize2 (-normalize2)
When specified, the samples will be scaled so the maximum sample
value is 1.
Write diagnostic images
(-writeDiagImages)
Writes a TIFF representation of the voronoi tessellation after each
iteration. The results is slightly different depending on which
sampling technique is employed but general each region has a unique
grey level, whilst mass centroids and region generators (samples) are
represented by red and green pixels. The output images are floating
point TIFFs. See example.
Write density (-writeDensity)
Writes the intensity map of the input image. I.e. the intensity
value(s) used internally in the calculations.
Voronoi Specific Arguments
Max centroidal offset (-mo offset)
Maximum offset (in pixels) allowed for an CVT calculate. Note that the
max centroidal iterations param will override this. Defaults to 2.
Max centroidal iterations (-mi
iterations)
Maximum number of centroidal iterations allowed. Regardless of the
current mass centroid offset, there will be no more than this number of
iterations. Defaults to 8.
Interleaved iterations (-ii iterations)
Number of interleaved iterations to perform. Defaults to 3.
Radius of perturbation (-rp offset)
When inserting new samples, they will be a maximum of offset pixels
from the insertion location. The idea is to keep new samples close to
but not on top of the high intensity region generators. The offset is a
percentage of image size. Defaults to 0.015 (1.5%).
Tips and Tricks
I recommend using the median cut sampling algorithm, it is very quick
and quite efficient.
When using median cut I suggest you use full size image maps as input
or use the resize option.
Known Problems
- all flavours of voronoi tesselations can fail at higher sampling
counts and this is dependant on the input image
References
- Efficient
Illumination by High Dynamic Range Images
- Centroidal
Voronoi Tessellations
- lightGen
- HDR Shop
- Paul Debevec