ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/bsdf.h
(Generate patch)

Comparing ray/src/common/bsdf.h (file contents):
Revision 2.4 by greg, Fri Feb 18 00:40:25 2011 UTC vs.
Revision 2.14 by greg, Wed Jun 8 15:37:46 2011 UTC

# Line 9 | Line 9
9   *      in the surface plane pointed to the right as seen from the front.
10   *      This means the Y-axis is "up" and the Z-axis is the surface normal.
11   *
12 < *  BSDF vectors always oriented away from surface, even when "incident."
12 > *  Note that we reverse the identification of "front" and "back" from
13 > *      the conventions used in WINDOW 6.  "Front" in our library points
14 > *      in the +Z direction, towards the interior of the space rather
15 > *      than the exterior.
16   *
17 + *  BSDF incident & exiting vectors are always oriented away from surface.
18 + *
19   *  Created by Greg Ward on 1/10/11.
20   *
21   */
# Line 28 | Line 33 | extern "C" {
33   #define SDnameLn        128             /* maximum BSDF name length */
34   #define SDmaxCh         3               /* maximum # spectral channels */
35  
36 < /* Component flags for SDsampBSDF() and SDhemiScatter() */
36 > /* Component flags for SDsampBSDF() and SDdirectHemi() */
37   #define SDsampR         0x1             /* include reflection */
38   #define SDsampT         0x2             /* include transmission */
39   #define SDsampS         0x3             /* include scattering (R+T) */
# Line 39 | Line 44 | extern "C" {
44   #define SDsampSpS       0x7             /* include non-diffuse scattering */
45   #define SDsampAll       0xF             /* include everything */
46  
47 < /* Projected solid angle query flags fos SDsizeBSDF() */
48 < #define SDqueryInc      0x1             /* query incoming vector */
49 < #define SDqueryOut      0x2             /* query outgoing vector */
50 < #define SDqueryMin      0x4             /* query minimum proj. solid angle */
46 < #define SDqueryMax      0x8             /* query maximum proj. solid angle */
47 > /* Projected solid angle query flags for SDsizeBSDF() */
48 > #define SDqueryVal      0x0             /* query single value */
49 > #define SDqueryMin      0x1             /* query minimum proj. solid angle */
50 > #define SDqueryMax      0x2             /* query maximum proj. solid angle */
51  
52   /* Error codes: normal return, out of memory, file i/o, file format, bad argument,
53                   bad data, unsupported feature, internal error, unknown error */
# Line 77 | Line 81 | typedef struct SDComp_s        SDComponent;
81   typedef const struct {
82                                          /* return non-diffuse BSDF */
83          int             (*getBSDFs)(float coef[SDmaxCh], const FVECT outVec,
84 <                                    const FVECT inVec, const void *dist);
84 >                                    const FVECT inVec, SDComponent *sdc);
85                                          /* query non-diffuse PSA for vector */
86 <        SDError         (*queryProjSA)(double *psa, const FVECT vec,
87 <                                                int qflags, const void *dist);
86 >        SDError         (*queryProjSA)(double *psa, const FVECT v1,
87 >                                                const RREAL *v2, int qflags,
88 >                                                SDComponent *sdc);
89                                          /* get cumulative distribution */
90          const SDCDst    *(*getCDist)(const FVECT inVec, SDComponent *sdc);
91                                          /* sample cumulative distribution */
92 <        SDError         (*sampCDist)(FVECT outVec, double randX,
92 >        SDError         (*sampCDist)(FVECT ioVec, double randX,
93                                                  const SDCDst *cdp);
94                                          /* free a spectral BSDF component */
95          void            (*freeSC)(void *dist);
# Line 108 | Line 113 | typedef struct {
113  
114   /* Loaded BSDF data */
115   typedef struct {
116 <        char            name[SDnameLn]; /* BSDF name (derived from file) */
116 >        char            name[SDnameLn]; /* BSDF name (usu. derived from file) */
117          char            *mgf;           /* geometric description (if any) */
118          float           dim[3];         /* width, height, thickness (meters) */
119          SDValue         rLambFront;     /* diffuse front reflectance */
# Line 125 | Line 130 | extern struct SDCache_s {
130                          *next;
131   } *SDcacheList;         /* Global BSDF cache */
132  
133 < /* BSDF cache retention preference */
134 < #define SDretainNone    0               /* free unreferenced data (default) */
135 < #define SDretainBSDFs   1               /* keep loaded BSDFs in cache */
133 > /* BSDF cache retention policies */
134 > #define SDretainNone    0               /* free unreferenced BSDF data */
135 > #define SDretainBSDFs   1               /* keep loaded BSDFs in memory */
136   #define SDretainAll     2               /* also keep cumulative cache data */
137  
138 < extern int              SDretainSet;    /* set to SDretainNone by default */
138 > extern int              SDretainSet;    /* =SDretainNone by default */
139  
140   /*****************************************************************
141   * The following routines are less commonly used by applications.
142   */
143  
144 < #define SDisLoaded(sd)  ((sd)->rLambFront.spec.clock != 0)
144 > #define SDisLoaded(sd)  ((sd)->rLambFront.spec.flags != 0)
145  
146   /* Report an error to the indicated stream (in English) */
147   extern SDError          SDreportEnglish(SDError ec, FILE *fp);
# Line 150 | Line 155 | extern SDSpectralDF    *SDnewSpectralDF(int nc);
155   /* Free a spectral distribution function */
156   extern void             SDfreeSpectralDF(SDSpectralDF *df);
157  
158 < /* Initialize an unused BSDF struct (clears to zeroes) */
159 < extern void             SDclearBSDF(SDData *sd);
158 > /* Initialize an unused BSDF struct and assign name (calls SDclipName) */
159 > extern void             SDclearBSDF(SDData *sd, const char *fname);
160  
161   /* Load a BSDF struct from the given file (keeps name unchanged) */
162   extern SDError          SDloadFile(SDData *sd, const char *fname);
# Line 166 | Line 171 | extern SDData          *SDgetCache(const char *bname);
171   extern void             SDfreeCumulativeCache(SDSpectralDF *df);
172  
173   /* Sample an individual BSDF component */
174 < extern SDError          SDsampComponent(SDValue *sv, FVECT outVec,
175 <                                        const FVECT inVec, double randX,
171 <                                        SDComponent *sdc);
174 > extern SDError          SDsampComponent(SDValue *sv, FVECT ioVec,
175 >                                        double randX, SDComponent *sdc);
176  
177   /* Convert 1-dimensional random variable to N-dimensional */
178   extern void             SDmultiSamp(double t[], int n, double randX);
# Line 185 | Line 189 | void                   SDdisk2square(double sq[2], double diskx, doubl
189   */
190  
191   /* Get BSDF from cache (or load and cache it on first call) */
192 < /* Report any problems to stderr and return NULL on failure */
192 > /* Report any problems to stderr (in English), return NULL on failure */
193   extern const SDData     *SDcacheFile(const char *fname);
194  
195 < /* Free a BSDF from our cache (clear all if NULL) */
195 > /* Free a BSDF from our cache (clear all if sd==NULL) */
196   extern void             SDfreeCache(const SDData *sd);
197  
198 < /* Query projected solid angle resolution for non-diffuse BSDF direction */
199 < extern SDError          SDsizeBSDF(double *projSA, const FVECT vec,
200 <                                        int qflags, const SDData *sd);
198 > /* Query projected solid angle resolution for non-diffuse BSDF direction(s) */
199 > extern SDError          SDsizeBSDF(double *projSA, const FVECT v1,
200 >                                        const RREAL *v2, int qflags,
201 >                                        const SDData *sd);
202  
203   /* Return BSDF for the given incident and scattered ray vectors */
204   extern SDError          SDevalBSDF(SDValue *sv, const FVECT outVec,
# Line 204 | Line 209 | extern double          SDdirectHemi(const FVECT inVec,
209                                          int sflags, const SDData *sd);
210  
211   /* Sample BSDF direction based on the given random variable */
212 < extern SDError          SDsampBSDF(SDValue *sv, FVECT outVec,
208 <                                        const FVECT inVec, double randX,
212 > extern SDError          SDsampBSDF(SDValue *sv, FVECT ioVec, double randX,
213                                          int sflags, const SDData *sd);
214  
215   /*****************************************************************
# Line 213 | Line 217 | extern SDError         SDsampBSDF(SDValue *sv, FVECT outVec,
217   * Directions may be passed unnormalized to these routines.
218   */
219  
220 < /* Compute World->BSDF transform from surface normal and up (Y) vector */
220 > /* Compute World->BSDF transform from surface normal and BSDF up vector */
221   extern SDError          SDcompXform(RREAL vMtx[3][3], const FVECT sNrm,
222                                          const FVECT uVec);
223  
# Line 223 | Line 227 | extern SDError         SDinvXform(RREAL iMtx[3][3], RREAL vMt
227   /* Transform and normalize direction (column) vector */
228   extern SDError          SDmapDir(FVECT resVec, RREAL vMtx[3][3],
229                                          const FVECT inpVec);
230 +
231 + /* Application-specific BSDF loading routine (not part of our library) */
232 + extern SDData           *loadBSDF(char *name);
233 +
234 + /* Application-specific BSDF error translator (not part of our library) */
235 + extern char             *transSDError(SDError ec);
236  
237   /*################################################################*/
238   /*######### DEPRECATED DEFINITIONS AWAITING PERMANENT REMOVAL #######*/

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines