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

Comparing ray/src/cv/bsdfrep.h (file contents):
Revision 2.2 by greg, Sat Oct 20 07:02:00 2012 UTC vs.
Revision 2.25 by greg, Mon Oct 26 21:12:20 2020 UTC

# Line 5 | Line 5
5   *      G. Ward
6   */
7  
8 + #ifndef _BSDFREP_H_
9 + #define _BSDFREP_H_
10 +
11   #include "bsdf.h"
12  
13 < #define DEBUG           1
13 > #ifdef __cplusplus
14 > extern "C" {
15 > #endif
16  
17   #ifndef GRIDRES
18 < #define GRIDRES         200             /* grid resolution per side */
18 > #define GRIDRES         (1<<8)          /* grid resolution per side */
19   #endif
20                                          /* convert to/from coded radians */
21   #define ANG2R(r)        (int)((r)*((1<<16)/M_PI))
22   #define R2ANG(c)        (((c)+.5)*(M_PI/(1<<16)))
23  
24 < typedef struct {
25 <        float           vsum;           /* DSF sum */
26 <        unsigned short  nval;           /* number of values in sum */
27 <        unsigned short  crad;           /* radius (coded angle) */
24 >                                        /* moderated cosine factor */
25 > #define COSF(z)         (fabs(z)*0.98 + 0.02)
26 >
27 > typedef union {
28 >        struct {
29 >                float           v;              /* DSF sum */
30 >                unsigned int    n;              /* number of values in sum */
31 >        }       sum;                    /* sum for averaging */
32 >        float   val[2];                 /* comparison values */
33   } GRIDVAL;                      /* grid value */
34  
35   typedef struct {
36          float           peak;           /* lobe value at peak */
37 +        C_CHROMA        chroma;         /* encoded chromaticity */
38          unsigned short  crad;           /* radius (coded angle) */
39 <        unsigned char   gx, gy;         /* grid position */
39 >        unsigned short  gx, gy;         /* grid position */
40   } RBFVAL;                       /* radial basis function value */
41  
42   struct s_rbfnode;               /* forward declaration of RBF struct */
# Line 57 | Line 68 | typedef struct s_rbfnode {
68   #define INP_QUAD3       4               /* 180-270 degree quadrant */
69   #define INP_QUAD4       8               /* 270-360 degree quadrant */
70  
71 +                                /* name and manufacturer if known */
72 + extern char             bsdf_name[];
73 + extern char             bsdf_manuf[];
74 +                                /* active grid resolution */
75 + extern int              grid_res;
76 +                                /* coverage/symmetry using INP_QUAD? flags */
77   extern int              inp_coverage;
78  
79                                  /* all incident angles in-plane so far? */
# Line 66 | Line 83 | extern int             single_plane_incident;
83   extern int              input_orient;
84   extern int              output_orient;
85  
86 +                                /* represented colorimetry */
87 + typedef enum {RBCphotopic, RBCtristimulus, RBCspectral, RBCunknown} RBColor;
88 +
89 + extern RBColor          rbf_colorimetry;
90 +
91 + extern const char       *RBCident[];
92 +
93 +                                /* log BSDF histogram */
94 + #define HISTLEN         256
95 + #define BSDF2BIG        (1./M_PI)
96 + #define BSDF2SML        1e-8
97 + #define HISTLNR         17.2759509              /* log(BSDF2BIG/BSDF2SML) */
98 + extern unsigned long    bsdf_hist[HISTLEN];
99 + #define histndx(v)      (int)(log((v)*(1./BSDF2SML))*(HISTLEN/HISTLNR))
100 + #define histval(i)      (exp(((i)+.5)*(HISTLNR/HISTLEN))*BSDF2SML)
101 +
102 +                                /* BSDF value for boundary regions */
103 + extern double           bsdf_min;
104 + extern double           bsdf_spec_val;
105 + extern double           bsdf_spec_rad;
106 +
107                                  /* processed incident DSF measurements */
108   extern RBFNODE          *dsf_list;
109  
110                                  /* RBF-linking matrices (edges) */
111   extern MIGRATION        *mig_list;
112  
113 <                                /* migration edges drawn in raster fashion */
114 < extern MIGRATION        *mig_grid[GRIDRES][GRIDRES];
77 <
78 < #define mtx_nrows(m)    ((m)->rbfv[0]->nrbf)
79 < #define mtx_ncols(m)    ((m)->rbfv[1]->nrbf)
113 > #define mtx_nrows(m)    (m)->rbfv[0]->nrbf
114 > #define mtx_ncols(m)    (m)->rbfv[1]->nrbf
115   #define mtx_coef(m,i,j) (m)->mtx[(i)*mtx_ncols(m) + (j)]
116   #define is_src(rbf,m)   ((rbf) == (m)->rbfv[0])
117   #define is_dest(rbf,m)  ((rbf) == (m)->rbfv[1])
# Line 87 | Line 122 | extern MIGRATION       *mig_grid[GRIDRES][GRIDRES];
122  
123   #define BSDFREP_FMT     "BSDF_RBFmesh"
124  
125 + #define BSDFREP_MAGIC   0x5a3c
126 +
127                                  /* global argv[0] */
128   extern char             *progname;
129  
130                                  /* get theta value in degrees [0,180) range */
131 < #define get_theta180(v) (180./M_PI)*acos((v)[2])
131 > #define get_theta180(v) ((180./M_PI)*Acos((v)[2]))
132                                  /* get phi value in degrees, [0,360) range */
133 < #define get_phi360(v)   ((180./M_PI)*atan2((v)[1],(v)[0]) + 180.)
133 > #define get_phi360(v)   ((180./M_PI)*atan2((v)[1],(v)[0]) + 360.*((v)[1]<0))
134  
135                                  /* our loaded grid for this incident angle */
136   extern double           theta_in_deg, phi_in_deg;
137   extern GRIDVAL          dsf_grid[GRIDRES][GRIDRES];
138 + extern float            (*spec_grid)[GRIDRES][GRIDRES];
139 + extern int              nspec_grid;
140  
141 +                                /* header line sharing callback */
142 + extern int              (*sir_headshare)(char *s);
143 +
144 +
145   /* Register new input direction */
146   extern int              new_input_direction(double new_theta, double new_phi);
147  
# Line 114 | Line 157 | extern void            rev_symmetry(FVECT vec, int sym);
157   /* Reverse symmetry for an RBF distribution */
158   extern void             rev_rbf_symmetry(RBFNODE *rbf, int sym);
159  
160 + /* Rotate RBF to correspond to given incident vector */
161 + extern void             rotate_rbf(RBFNODE *rbf, const FVECT invec);
162 +
163   /* Compute volume associated with Gaussian lobe */
164   extern double           rbf_volume(const RBFVAL *rbfp);
165  
# Line 123 | Line 169 | extern void            ovec_from_pos(FVECT vec, int xpos, int yp
169   /* Compute grid position from normalized input/output vector */
170   extern void             pos_from_vec(int pos[2], const FVECT vec);
171  
172 < /* Evaluate RBF for DSF at the given normalized outgoing direction */
172 > /* Evaluate BSDF at the given normalized outgoing direction */
173   extern double           eval_rbfrep(const RBFNODE *rp, const FVECT outvec);
174  
175 + extern SDError          eval_rbfcol(SDValue *sv,
176 +                                        const RBFNODE *rp, const FVECT outvec);
177 +
178   /* Insert a new directional scattering function in our global list */
179   extern int              insert_dsf(RBFNODE *newrbf);
180  
# Line 143 | Line 192 | extern int             is_rev_tri(const FVECT v1,
192   /* Find vertices completing triangles on either side of the given edge */
193   extern int              get_triangles(RBFNODE *rbfv[2], const MIGRATION *mig);
194  
195 + /* Clear our BSDF representation and free memory */
196 + extern void             clear_bsdf_rep(void);
197 +
198   /* Write our BSDF mesh interpolant out to the given binary stream */
199   extern void             save_bsdf_rep(FILE *ofp);
200  
201   /* Read a BSDF mesh interpolant from the given binary stream */
202   extern int              load_bsdf_rep(FILE *ifp);
203  
204 + /* Set up visible spectrum sampling */
205 + extern void             set_spectral_samples(int nspec);
206 +
207   /* Start new DSF input grid */
208   extern void             new_bsdf_data(double new_theta, double new_phi);
209  
210   /* Add BSDF data point */
211   extern void             add_bsdf_data(double theta_out, double phi_out,
212 <                                        double val, int isDSF);
212 >                                        const double val[], int isDSF);
213  
214   /* Count up filled nodes and build RBF representation from current grid */
215   extern RBFNODE *        make_rbfrep(void);
# Line 162 | Line 217 | extern RBFNODE *       make_rbfrep(void);
217   /* Build our triangle mesh from recorded RBFs */
218   extern void             build_mesh(void);
219  
165 /* Draw edge list into mig_grid array */
166 extern void             draw_edges(void);
167
220   /* Find edge(s) for interpolating the given vector, applying symmetry */
221   extern int              get_interp(MIGRATION *miga[3], FVECT invec);
222  
223 + /* Return single-lobe specular RBF for the given incident direction */
224 + extern RBFNODE *        def_rbf_spec(const FVECT invec);
225 +
226 + /* Advect and allocate new RBF along edge (internal call) */
227 + extern RBFNODE *        e_advect_rbf(const MIGRATION *mig,
228 +                                        const FVECT invec, int lobe_lim);
229 +
230 + /* Compute distance between two RBF lobes (internal call) */
231 + extern double           lobe_distance(RBFVAL *rbf1, RBFVAL *rbf2);
232 +
233 + /* Compute mass transport plan (internal call) */
234 + extern void             plan_transport(MIGRATION *mig);
235 +
236   /* Partially advect between recorded incident angles and allocate new RBF */
237 < extern RBFNODE *        advect_rbf(const FVECT invec);
237 > extern RBFNODE *        advect_rbf(const FVECT invec, int lobe_lim);
238 >
239 > #ifdef __cplusplus
240 > }
241 > #endif
242 > #endif  /* _BSDFREP_H_ */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines