--- ray/src/common/bsdf.h 2011/02/19 01:48:59 2.6 +++ ray/src/common/bsdf.h 2011/04/24 19:39:21 2.12 @@ -1,4 +1,4 @@ -/* RCSid $Id: bsdf.h,v 2.6 2011/02/19 01:48:59 greg Exp $ */ +/* RCSid $Id: bsdf.h,v 2.12 2011/04/24 19:39:21 greg Exp $ */ /* * bsdf.h * @@ -9,6 +9,11 @@ * in the surface plane pointed to the right as seen from the front. * This means the Y-axis is "up" and the Z-axis is the surface normal. * + * Note that we reverse the identification of "front" and "back" from + * the conventions used in WINDOW 6. "Front" in our library points + * in the +Z direction, towards the interior of the space rather + * than the exterior. + * * BSDF vectors always oriented away from surface, even when "incident." * * Created by Greg Ward on 1/10/11. @@ -28,7 +33,7 @@ extern "C" { #define SDnameLn 128 /* maximum BSDF name length */ #define SDmaxCh 3 /* maximum # spectral channels */ -/* Component flags for SDsampBSDF() and SDhemiScatter() */ +/* Component flags for SDsampBSDF() and SDdirectHemi() */ #define SDsampR 0x1 /* include reflection */ #define SDsampT 0x2 /* include transmission */ #define SDsampS 0x3 /* include scattering (R+T) */ @@ -39,11 +44,10 @@ extern "C" { #define SDsampSpS 0x7 /* include non-diffuse scattering */ #define SDsampAll 0xF /* include everything */ -/* Projected solid angle query flags fos SDsizeBSDF() */ -#define SDqueryInc 0x1 /* query incoming vector */ -#define SDqueryOut 0x2 /* query outgoing vector */ -#define SDqueryMin 0x4 /* query minimum proj. solid angle */ -#define SDqueryMax 0x8 /* query maximum proj. solid angle */ +/* Projected solid angle query flags for SDsizeBSDF() */ +#define SDqueryVal 0x0 /* query single value */ +#define SDqueryMin 0x1 /* query minimum proj. solid angle */ +#define SDqueryMax 0x2 /* query maximum proj. solid angle */ /* Error codes: normal return, out of memory, file i/o, file format, bad argument, bad data, unsupported feature, internal error, unknown error */ @@ -77,14 +81,15 @@ typedef struct SDComp_s SDComponent; typedef const struct { /* return non-diffuse BSDF */ int (*getBSDFs)(float coef[SDmaxCh], const FVECT outVec, - const FVECT inVec, const void *dist); + const FVECT inVec, SDComponent *sdc); /* query non-diffuse PSA for vector */ - SDError (*queryProjSA)(double *psa, const FVECT vec, - int qflags, const void *dist); + SDError (*queryProjSA)(double *psa, const FVECT v1, + const RREAL *v2, int qflags, + SDComponent *sdc); /* get cumulative distribution */ const SDCDst *(*getCDist)(const FVECT inVec, SDComponent *sdc); /* sample cumulative distribution */ - SDError (*sampCDist)(FVECT outVec, double randX, + SDError (*sampCDist)(FVECT ioVec, double randX, const SDCDst *cdp); /* free a spectral BSDF component */ void (*freeSC)(void *dist); @@ -150,8 +155,8 @@ extern SDSpectralDF *SDnewSpectralDF(int nc); /* Free a spectral distribution function */ extern void SDfreeSpectralDF(SDSpectralDF *df); -/* Initialize an unused BSDF struct (clears to zeroes) */ -extern void SDclearBSDF(SDData *sd); +/* Initialize an unused BSDF struct and assign name (calls SDclipName) */ +extern void SDclearBSDF(SDData *sd, const char *fname); /* Load a BSDF struct from the given file (keeps name unchanged) */ extern SDError SDloadFile(SDData *sd, const char *fname); @@ -166,9 +171,8 @@ extern SDData *SDgetCache(const char *bname); extern void SDfreeCumulativeCache(SDSpectralDF *df); /* Sample an individual BSDF component */ -extern SDError SDsampComponent(SDValue *sv, FVECT outVec, - const FVECT inVec, double randX, - SDComponent *sdc); +extern SDError SDsampComponent(SDValue *sv, FVECT ioVec, + double randX, SDComponent *sdc); /* Convert 1-dimensional random variable to N-dimensional */ extern void SDmultiSamp(double t[], int n, double randX); @@ -191,9 +195,10 @@ extern const SDData *SDcacheFile(const char *fname); /* Free a BSDF from our cache (clear all if NULL) */ extern void SDfreeCache(const SDData *sd); -/* Query projected solid angle resolution for non-diffuse BSDF direction */ -extern SDError SDsizeBSDF(double *projSA, const FVECT vec, - int qflags, const SDData *sd); +/* Query projected solid angle resolution for non-diffuse BSDF direction(s) */ +extern SDError SDsizeBSDF(double *projSA, const FVECT v1, + const RREAL *v2, int qflags, + const SDData *sd); /* Return BSDF for the given incident and scattered ray vectors */ extern SDError SDevalBSDF(SDValue *sv, const FVECT outVec, @@ -204,8 +209,7 @@ extern double SDdirectHemi(const FVECT inVec, int sflags, const SDData *sd); /* Sample BSDF direction based on the given random variable */ -extern SDError SDsampBSDF(SDValue *sv, FVECT outVec, - const FVECT inVec, double randX, +extern SDError SDsampBSDF(SDValue *sv, FVECT ioVec, double randX, int sflags, const SDData *sd); /*****************************************************************