| 14 |
|
* in the +Z direction, towards the interior of the space rather |
| 15 |
|
* than the exterior. |
| 16 |
|
* |
| 17 |
< |
* BSDF vectors always oriented away from surface, even when "incident." |
| 17 |
> |
* BSDF incident & exiting vectors are always oriented away from surface. |
| 18 |
|
* |
| 19 |
|
* Created by Greg Ward on 1/10/11. |
| 20 |
|
* |
| 30 |
|
extern "C" { |
| 31 |
|
#endif |
| 32 |
|
|
| 33 |
+ |
#ifdef _WIN32 |
| 34 |
+ |
#define strcasecmp stricmp |
| 35 |
+ |
#endif |
| 36 |
+ |
|
| 37 |
|
#define SDnameLn 128 /* maximum BSDF name length */ |
| 38 |
|
#define SDmaxCh 3 /* maximum # spectral channels */ |
| 39 |
|
|
| 85 |
|
typedef const struct { |
| 86 |
|
/* return non-diffuse BSDF */ |
| 87 |
|
int (*getBSDFs)(float coef[SDmaxCh], const FVECT outVec, |
| 88 |
< |
const FVECT inVec, const void *dist); |
| 88 |
> |
const FVECT inVec, SDComponent *sdc); |
| 89 |
|
/* query non-diffuse PSA for vector */ |
| 90 |
|
SDError (*queryProjSA)(double *psa, const FVECT v1, |
| 91 |
|
const RREAL *v2, int qflags, |
| 92 |
< |
const void *dist); |
| 92 |
> |
SDComponent *sdc); |
| 93 |
|
/* get cumulative distribution */ |
| 94 |
|
const SDCDst *(*getCDist)(const FVECT inVec, SDComponent *sdc); |
| 95 |
|
/* sample cumulative distribution */ |
| 96 |
< |
SDError (*sampCDist)(FVECT outVec, double randX, |
| 96 |
> |
SDError (*sampCDist)(FVECT ioVec, double randX, |
| 97 |
|
const SDCDst *cdp); |
| 98 |
|
/* free a spectral BSDF component */ |
| 99 |
|
void (*freeSC)(void *dist); |
| 117 |
|
|
| 118 |
|
/* Loaded BSDF data */ |
| 119 |
|
typedef struct { |
| 120 |
< |
char name[SDnameLn]; /* BSDF name (derived from file) */ |
| 120 |
> |
char name[SDnameLn]; /* BSDF name (usu. derived from file) */ |
| 121 |
|
char *mgf; /* geometric description (if any) */ |
| 122 |
|
float dim[3]; /* width, height, thickness (meters) */ |
| 123 |
|
SDValue rLambFront; /* diffuse front reflectance */ |
| 134 |
|
*next; |
| 135 |
|
} *SDcacheList; /* Global BSDF cache */ |
| 136 |
|
|
| 137 |
< |
/* BSDF cache retention preference */ |
| 138 |
< |
#define SDretainNone 0 /* free unreferenced data (default) */ |
| 139 |
< |
#define SDretainBSDFs 1 /* keep loaded BSDFs in cache */ |
| 137 |
> |
/* BSDF cache retention policies */ |
| 138 |
> |
#define SDretainNone 0 /* free unreferenced BSDF data */ |
| 139 |
> |
#define SDretainBSDFs 1 /* keep loaded BSDFs in memory */ |
| 140 |
|
#define SDretainAll 2 /* also keep cumulative cache data */ |
| 141 |
|
|
| 142 |
< |
extern int SDretainSet; /* set to SDretainNone by default */ |
| 142 |
> |
extern int SDretainSet; /* =SDretainNone by default */ |
| 143 |
|
|
| 144 |
|
/***************************************************************** |
| 145 |
|
* The following routines are less commonly used by applications. |
| 175 |
|
extern void SDfreeCumulativeCache(SDSpectralDF *df); |
| 176 |
|
|
| 177 |
|
/* Sample an individual BSDF component */ |
| 178 |
< |
extern SDError SDsampComponent(SDValue *sv, FVECT outVec, |
| 179 |
< |
const FVECT inVec, double randX, |
| 176 |
< |
SDComponent *sdc); |
| 178 |
> |
extern SDError SDsampComponent(SDValue *sv, FVECT ioVec, |
| 179 |
> |
double randX, SDComponent *sdc); |
| 180 |
|
|
| 181 |
|
/* Convert 1-dimensional random variable to N-dimensional */ |
| 182 |
|
extern void SDmultiSamp(double t[], int n, double randX); |
| 193 |
|
*/ |
| 194 |
|
|
| 195 |
|
/* Get BSDF from cache (or load and cache it on first call) */ |
| 196 |
< |
/* Report any problems to stderr and return NULL on failure */ |
| 196 |
> |
/* Report any problems to stderr (in English), return NULL on failure */ |
| 197 |
|
extern const SDData *SDcacheFile(const char *fname); |
| 198 |
|
|
| 199 |
< |
/* Free a BSDF from our cache (clear all if NULL) */ |
| 199 |
> |
/* Free a BSDF from our cache (clear all if sd==NULL) */ |
| 200 |
|
extern void SDfreeCache(const SDData *sd); |
| 201 |
|
|
| 202 |
|
/* Query projected solid angle resolution for non-diffuse BSDF direction(s) */ |
| 213 |
|
int sflags, const SDData *sd); |
| 214 |
|
|
| 215 |
|
/* Sample BSDF direction based on the given random variable */ |
| 216 |
< |
extern SDError SDsampBSDF(SDValue *sv, FVECT outVec, |
| 214 |
< |
const FVECT inVec, double randX, |
| 216 |
> |
extern SDError SDsampBSDF(SDValue *sv, FVECT ioVec, double randX, |
| 217 |
|
int sflags, const SDData *sd); |
| 218 |
|
|
| 219 |
|
/***************************************************************** |
| 221 |
|
* Directions may be passed unnormalized to these routines. |
| 222 |
|
*/ |
| 223 |
|
|
| 224 |
< |
/* Compute World->BSDF transform from surface normal and up (Y) vector */ |
| 224 |
> |
/* Compute World->BSDF transform from surface normal and BSDF up vector */ |
| 225 |
|
extern SDError SDcompXform(RREAL vMtx[3][3], const FVECT sNrm, |
| 226 |
|
const FVECT uVec); |
| 227 |
|
|
| 232 |
|
extern SDError SDmapDir(FVECT resVec, RREAL vMtx[3][3], |
| 233 |
|
const FVECT inpVec); |
| 234 |
|
|
| 235 |
< |
/* System-specific BSDF loading routine (not part of our library) */ |
| 235 |
> |
/* Application-specific BSDF loading routine (not part of our library) */ |
| 236 |
|
extern SDData *loadBSDF(char *name); |
| 237 |
|
|
| 238 |
< |
/* System-specific BSDF error translator (not part of our library) */ |
| 238 |
> |
/* Application-specific BSDF error translator (not part of our library) */ |
| 239 |
|
extern char *transSDError(SDError ec); |
| 240 |
|
|
| 241 |
|
/*################################################################*/ |