This is a reflection model (BRDF) viewer written by students in the
course 15-860.
See http://www.cs.cmu.edu/afs/cs/project/classes-ph/860.96/pub/www/860.html
for info on the course.

It's in an unfinished state, so caveat emptor.

For info on this distribution of software, and how to compile the other
libraries required by this program (xforms and VL) if that is necessary,
see the nearby file DISTRIB.

===== HOW TO RUN PROGRAM

The shell variable LD_LIBRARY_PATH must include the directory containing
libforms.so.  On a CMU graphics lab SGI, the appropriate command is
    setenv LD_LIBRARY_PATH /usr/local/lib
otherwise you'll need to set this variable appropriately.
Then run
    brdfview

"Theta" slider changes incident angle.
"Phi" changes azimuth of incident ray (simply spins the BRDF around,
    for isotropic BRDF's).
White line is incident ray direction, green line is ideal specular reflection.
There's a choice of four reflection models in the upper right
  (pull-down menu): Phong, Cook-Torrance, Oren-Nayar, or He.
Sliders on the right control the model parameters specific to the chosen
    illumination model, and are labeled below each slider.
View control sliders in lower left:
    "y" slider spins the BRDF around (same as "Phi" slider for isotropic BRDFs)
Left/middle/right click on the window to zoom in/reset/out, respectively.
The "Radiance" button near bottom:
    when off, displays the BRDF, which includes factor of 1/cos(theta_i),
	causing specular lobes to shoot off screen at grazing angles
    when on, displays something you can think of as radiance.
	It is brdf*cos(theta_i), and is more intuitive.
"Reset" resets all the reflection model parameters to their defaults.

Phong parameters:
    kd = diffuse coefficient
    ks = specular coefficient
    expon = exponent: higher for smoother surface, smaller for rougher
    mat_r, mat_g, mat_b = material red, green, and blue reflectance
	(spectral multipliers on everything else; these parameters are
	mostly ignored by the current user interface; the program is
	making a polar plot of the reflectance function for red wavelength).
try tweaking expon and Theta

Cook-Torrance parameters:
    m = RMS slope of facets (a higher slope signifies a rougher surface)
    d = coefficient of diffuse reflectance compared to specular
    n = index of refraction of material (larger -> more specular)
    k = extinction coefficient (not currently used)
    Rd_red, Rd_blue, Rd_green = Diffuse reflectance (surface color)
try tweaking m and n

Oren-Nayar parameters:
    sigma = roughness (stdev of facet angle in radians)
    rho = albedo (reflectance of one micro-facet)
try tweaking Theta

He parameters:
    n_r = index of refraction, real part
    n_i = index of refraction, imag part
    tau = autocorrelation length (tangential spacing between peaks)
    sigma0 = roughness (stdev of height)
    diffuse = uniform diffuse coefficient
Try tweaking any of the first four parameters.
Setting tau large or sigma0 small (.02) makes reflection mirror-like.
Can you model a sperm whale, a toilet, a mushroom :-) ?

===== GUIDE TO SOURCE CODE

illum.[HC] - base class that reflection models are derived from, Paul Heckbert
phong.[HC] - Phong illumination model, impl by Paul Heckbert
cook_torrance.[HC] - impl by Noah Gibbs
oren-nayar.[HC] - impl by Rob DeLine
heBRDF.[HC] - impl by Andrew Willmott, working from code by Greg Ward

glxf.[HC] - generic Opengl & xforms init code by Paul H. & Andrew Willmott
ui_form.[HC] - xforms stuff, mostly created by fdesign program, Tom Kang
ui_form.fd - UI stuff, created by fdesign program, Tom Kang
brdfview.[HC] - main program, Tom Kang & Paul Heckbert

===== CHANGE LOG

7 Oct 1997 fixed bug in oren-nayar.C (was calculating vn & ln wrong)
	    discovered by Szymon M. Rusinkiewicz, smr@cs.stanford.edu


Paul Heckbert   9 Nov 1996, 23 June 1997
ph@cs.cmu.edu
