(N.b.: Moved to RADIANCE Dev)
David wrote:
Hi,
I am in the process of developing a new BRTDF / BSDF as a part of my PhD
Does anyone have any advice or suggestions on how I go about incorporating the algorithms into Radiance, and especially how I go about incorporating Monte Carlo sampling into the BRTDF / BSDF within Radiance?
Hi Dave,
you might wanna check normal.c for a simpler example. There, m_normal() does all the sampling, relegating calls to dirnorm() (via direct()), gaussamp(), and ambient() to sample the direct, indirect specular, and indirect diffuse components, respectively. You'll want to split your BRDF into similar components, with stratified sampling for the diffuse stuff and importance sampling for the specular (glossy?) stuff.
Note that you'll need to enter the material and its sampling function in the object function table in otypes.h and initotypes.c.
Stratified sampling is cos-weighted and trivial; see Dutre's Globillum Compendium (http://www.cs.kuleuven.ac.be/~phil/GI/\) and Greg's implementation (interpretation?) in divsample() in ambcomp.c.
Importance sampling is a lot more involved. Basically you've got two options:
1) Perform the Monte Carlo inversion of your PDF (probability density function, in this case proportional to your BRDF * cos(theta_out)) analytically. On paper. By hand. Looking at your list of specs for the BRDF, that should be *loads* of fun! :^)
2) Invert the PDF numerically, the dumb and slow way, by uniformly choosing intervals in a lookup table containing the CDF (cumulative density function). This is insanely slow, because the table must be constructed for *every* reflection. However, If your BRDF defies analytic inversion, this is the only way to go. (This is also the reason I never bothered to include support for user-defined BRDFs in the RADIANCE photon map).
Um... happy sampling, mate. :^)
--Roland
ยทยทยท
--
Roland Schregle
PhD candidate, Fraunhofer Institute for Solar Energy Systems
RADIANCE Photon Map page: www.ise.fhg.de/radiance/photon-map
END OF LINE. (MCP)