Advanced Global Illumination using Lightcuts - PBRT code

Next to the 4 new "SurfaceIntegrator" plugins I wrote, I also modified some files in the PBRT core (ex. bounding a BSDF, splitting a light source, calculating multiple pixels at once, ...). A zip file containing all source code, a compiled version and a test scene (the Conference scene) is available for win32 and linux. The win32 version contains all necessary libraries but the linux version requires the OpenEXR library (i.e. the same requirements as pbrt v1.03).
Not all materials (due to the required upper bound) and light types (due to the required discretisation) are supported. The supported materials are: "matte", "plastic", "glass" and "mirror". For the latter 2 a new ray is traced. The supported light sources are: "area", "point", "distant", "infinite" and "infinitesample".
You can use this source code for whatever you want but mention my name (and other relevant stuff like e-mail) if you should redistribute the code or a binary, be it modified or not. You obviously also have to respect the original PBRT license. Dont hesitate to send me questions, bug reports, suggestions or anything else that is somewhat related (my e-mail is at bottom of this page).

Plugins:
1. Lightcuts
2. Multidimensional Lightcuts
3. Lightcuts + visibility bounds
4. Coherent Lightcuts

1. Lightcuts

Plugin name:
"lightcuts"
Description:
My implementation of the Lightcuts algorithm.
Parameters:
NameTypeDefault valueDescription
"numlightscale" float 256 The number of simple light sources used for the discretisation of a light source is "numlightscale" x "nsamples". The "nsamples" parameter is defined with a light source. A point light or directional light is obviously used without discretisation.
"maxrelerror" float 0.01 The maximum allowed relative error (i.e. 0.01 is 1%).
"avglum" float 0.0 The adaptation luminance (La) used in the improved perceptual heuristic proposed in the Multidimensional Lightcuts paper. A value of 0 results in the heuristic proposed in the Lightcuts paper.
"maxcutsize" integer 1000 The maximum cut size.
"pixelvalue" string "illumination" The value that is written to the film. The possible values are: "illumination" (the illumination that was calculated), "cutsize" (the size of the cut) and "totmaxerr" (the total maximum error).
"maxspeculardepth" integer 5 The number of recursive specular reflections or refractions that is calculated.
"numVLpaths" integer 0 The number of paths used to generate the virtual light sources for the indirect illumination. A value of 0 results in only direct illumination.
"datasaving" string "" This parameter allows saving some of the internal data (which can be visualized in the LightcutVis tool I wrote). The format of the string is: <filename>_<flags>. Here <filename> is the name of the file (without extention) where the data is stored and <flags> describes the data that is saved. Possible flags are 't' (the light tree is saved in <filename>.ltree) and 'c' (the light cuts are saved in <filename>.lcut).

Compilation options:
NameDescription
TD_CLUSTERINGIf this is defined, the top-down algorithm is used to construct the light trees. Otherwise the original bottom-up algorithm is used.
TRIVIAL_LOW_BOUNDIf this is defined, a trivial lower bound is used to improve the error estimate a bit. Otherwise only the upper bound is used like in the Lightcuts paper.

Note: in the compiled version both options were disabled.

2. Multidimensional Lightcuts

Plugin name:
"multilightcuts"
Description:
My implementation of the Multidimensional Lightcuts algorithm.
Parameters:
NameTypeDefault valueDescription
"numlightscale" float 256 The number of simple light sources used for the discretisation of a light source is "numlightscale" x "nsamples". The "nsamples" parameter is defined with a light source. A point light or directional light is obviously used without discretisation.
"maxrelerror" float 0.01 The maximum allowed relative error (i.e. 0.01 is 1%).
"avglum" float 0.0 The adaptation luminance (La) used in the improved perceptual heuristic proposed in the Multidimensional Lightcuts paper. A good estimate of this value is required to limit the contribution of virtual light sources.
"maxcutsize" integer 2000 The maximum cut size.
"pixelvalue" string "illumination" The value that is written to the film. The possible values are: "illumination" (the illumination that was calculated), "cutsize" (the size of the cut), "totmaxerr" (the total maximum error) and "lightrefinepercentage" (the fraction of all cut refinements that refined the the node in the light tree.
"maxspeculardepth" integer 5 The number of recursive specular reflections or refractions that is calculated.
"numVLpaths" integer 0 The number of paths used to generate the virtual light sources for the indirect illumination. A value of 0 results in only direct illumination.
"stepsize" float 1.0 The distance along a ray between 2 gather points in a participating medium.

Compilation options:
NameDescription
TD_CLUSTERINGIf this is defined, the top-down algorithm is used to construct the light trees. Otherwise the original bottom-up algorithm is used.
NUM_LIGHTREPRThis options defines the number of representative light sources that is used for each node in the light tree. If it is not defined 1 representative is used for each light cluster.
NUM_GATHERREPRThis options defines the number of representative light sources that is used for each node in the gather tree. If it is not defined 1 representative is used for each gather cluster.
REFINEHEURThis option defines the refinement heuristic that is used (i.e. the heuristic to determine whether the node in the gather or light tree is refined). The possible values are 0 (the original heuristic), 1 (the upper bound heuristic) and 2 (the minimal upper bound heuristic).

Note: in the compiled version TD_CLUSTERING is not defined, NUM_LIGHTREPR=16, NUM_GATHERREPR=8 and REFINEHEUR=2.

3. Lightcuts + visibility bounds

Plugin name:
"vislightcuts"
Description:
My implementation of the Lightcuts algorithm with a more tight upper and lower bound.
Parameters:
NameTypeDefault valueDescription
"numlightscale" float 256 The number of simple light sources used for the discretisation of a light source is "numlightscale" x "nsamples". The "nsamples" parameter is defined with a light source. A point light or directional light is obviously used without discretisation.
"maxrelerror" float 0.01 The maximum allowed relative error (i.e. 0.01 is 1%).
"avglum" float 0.0 The adaptation luminance (La) used in the improved perceptual heuristic proposed in the Multidimensional Lightcuts paper. A value of 0 results in the heuristic proposed in the Lightcuts paper.
"maxcutsize" integer 1000 The maximum cut size.
"pixelvalue" string "illumination" The value that is written to the film. The possible values are: "illumination" (the illumination that was calculated), "cutsize" (the size of the cut) and "totmaxerr" (the total maximum error).
"maxspeculardepth" integer 5 The number of recursive specular reflections or refractions that is calculated.
"numVLpaths" integer 0 The number of paths used to generate the virtual light sources for the indirect illumination. A value of 0 results in only direct illumination.
"datasaving" string "" This parameter allows saving some of the internal data (which can be visualized in the LightcutVis tool I wrote). The format of the string is: <filename>_<flags>. Here <filename> is the name of the file (without extention) where the data is stored and <flags> describes the data that is saved. Possible flags are 't' (the light tree is saved in <filename>.ltree), 'c' (the light cuts are saved in <filename>.lcut) and 'v' (the preprocess for the visibility is saved in <filename>.vis)
"vis_lowbound" bool true Whether a more tight lower bound is used or not.
"vis_upbound" bool true Whether a more tight upper bound is used or not.
"vis_numtargetcells" integer 100000 The target number of cells for the visibility preprocess.
"vis_maxrays" integer 1000 The maximum number of rays used for each cel for each cluster in the visibility preprocess.
"vis_minrays" integer "vis_maxrays"/100 The minimum number of rays used for each cel for each cluster in the visibility preprocess.
"vis_maxhemipercent" float 10 The maximum percentage of the total hemisphere that a cluster covers in the visibility preprocess.

Compilation options:
NameDescription
TD_CLUSTERINGIf this is defined, the top-down algorithm is used to construct the light trees. Otherwise the original bottom-up algorithm is used.
TRIVIAL_LOW_BOUNDIf this is defined, a trivial lower bound is used to improve the error estimate a bit. Otherwise only the upper bound is used like in the Lightcuts paper.
LOW_BOUNDIf this is defined, a non-trivial lower bound is calculated. This option automatically enables the above option.

Opmerking: in the compiled version all options were enabled.

4. Coherent Lightcuts

Plugin name:
"cohlightcuts"
Description:
My implemenation of the Coherent Lightcuts algorithm.
Parameters:
NameTypeDefault valueDescription
"numlightscale" float 256 The number of simple light sources used for the discretisation of a light source is "numlightscale" x "nsamples". The "nsamples" parameter is defined with a light source. A point light or directional light is obviously used without discretisation.
"maxrelerror" float 0.01 The maximum allowed relative error (i.e. 0.01 is 1%).
"avglum" float 0.0 The adaptation luminance (La) used in the improved perceptual heuristic proposed in the Multidimensional Lightcuts paper. A value of 0 results in the heuristic proposed in the Lightcuts paper.
"maxcutsize" integer 1000 The maximum cut size.
"pixelvalue" string "illumination" The value that is written to the film. The possible values are: "illumination" (the illumination that was calculated), "cutsize" (the size of the cut) and "totmaxerr" (the total maximum error).
"maxspeculardepth" integer 5 The number of recursive specular reflections or refractions that is calculated.
"numVLpaths" integer 0 The number of paths used to generate the virtual light sources for the indirect illumination. A value of 0 results in only direct illumination.
"datasaving" string "" This parameter allows saving some of the internal data (which can be visualized in the LightcutVis tool I wrote). The format of the string is: <filename>_<flags>. Here <filename> is the name of the file (without extention) where the data is stored and <flags> describes the data that is saved. The only possible flag is 't' (the light tree is saved in <filename>.ltree).
"blocksize" integer 16 The side length of the initial blocks in pixels (i.e. 16 results in an initial block size of 16x16 pixels).

Compilation options:
NameDescription
TD_CLUSTERINGIf this is defined, the top-down algorithm is used to construct the light trees. Otherwise the original bottom-up algorithm is used.
TRIVIAL_LOW_BOUNDIf this is defined, a trivial lower bound is used to improve the error estimate a bit. Otherwise only the upper bound is used like in the Lightcuts paper.

Note: in the compiled version only the TRIVIAL_LOW_BOUND options was enabled.

Thomas De Bodt (thomas_de_bodt@hotmail.com) - Katholieke Universiteit Leuven - 2007-2008