This directory contains code to prefilter the environment maps as per
the paper "Frequency Space Environment Map Rendering" by Ramamoorthi
and Hanrahan, SIGGRAPH 2002.  The code is currently being run on a
Linux PC, and is compiled simply using make.  Appropriate changes to
the Makefile may be required based on your platform, but for the most
part, the code is fairly portable.  Some care may be required in
ensuring that the complex class works.

An example execution is as follows:

% refenvshrm lightfile baseout mulfac brdftype options

    The parameters are as follows:
    lightfile: Incident illumination spherical harmonic coefficients
    baseout: base for output files generated
    mulfac: Scaling factor for output file
    brdftype: sigma (N.H), lafortune, curet, mccool, kaykajiya
    options: different for each of the brdf types

Example 1: 
----------

% refenvshrm lightfiles/grace.out output/orangecuretgrace 2000.0 curet
brdffiles/zercoeffs 55

    The parameters are explained as follows:

    lightfiles/grace.out stores spherical harmonic coefficients for
the Grace Cathedral light probe [there are four probes in lightfiles/
courtesy of Paul Debevec (original data available from
http://www.debevec.org) ; grace.out grove.out stpeters.out uffizi.out]

    output/orangecuretgrace The output base name.  The files created
by the program are output/orangecuretgrace.shrm [which writes out the
full SHRM ; Note the first line which contains the full command line
used and the maximum value of p] and cubemap shrms for actual use in
rendering, i.e.  orangecuretgrace_??.shrm [with ?? = nx,ny,nz,px,py,pz]

    2000.0 A normalizing multiplicative factor

    curet Indicates the BRDF is from the CURET database

    brdffiles/zercoeffs File of Zernike coefficients for CURET database
 
    55 Sample number for orange within that database

The program then spits out a lot of information, which may be ignored
to first order, but can be helpful for checkpointing/debugging.  The
output should be the files orangecuretgrace.shrm and orangecuretgrace_??.shrm

More examples:
--------------

% refenvshrm lightfiles/grove.out output/krylongrove 1.0 mccool brdffiles/krylonblue .114 0.0555595 0.0841939 19.69

[This generates the result for the grove light probe using krylon blue 
paint measurements reconstructed using McCool et al.'s factorization.
The relevant files are in brdffiles/krylonblue?.ppm ?=p,q,h The next
numbers are scaling factors in RGB and the specular component.
Details are found from Mike McCool's website; 
http://www.cgl.uwaterloo.ca/Projects/rendering/Shading/database.html ]

% refenvshrm lightfiles/stpeters.out output/sigma1stpeters 20.0 sigma 0.125

[This is the N.H model with sigma = 0.125]

% refenvshrm lightfiles/uffizi.out output/lafortune1 1.0 lafortune brdffiles/lafortune1 

[lafortune1 describes specific parameters to a Lafortune model]

% refenvshrm lightfiles/grace.out output/kay32grace 1000.0 kaykajiya 32

[32 is the exponent used in the Kay-Kajiya anisotropic model]

Viewing the SHRMs:
------------------

