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

Comparing ray/src/cv/bsdfmesh.c (file contents):
Revision 2.12 by greg, Sun Oct 27 20:16:06 2013 UTC vs.
Revision 2.30 by greg, Thu Aug 21 10:33:48 2014 UTC

# Line 18 | Line 18 | static const char RCSid[] = "$Id$";
18   #include <string.h>
19   #include <math.h>
20   #include "bsdfrep.h"
21 +
22 + #ifndef NEIGH_FACT2
23 + #define NEIGH_FACT2     0.1     /* empirical neighborhood distance weight */
24 + #endif
25                                  /* number of processes to run */
26   int                     nprocs = 1;
27                                  /* number of children (-1 in child) */
28   static int              nchild = 0;
29  
30 < typedef struct {
31 <        int             nrows, ncols;   /* array size (matches migration) */
32 <        float           *price;         /* migration prices */
33 <        short           *sord;          /* sort for each row, low to high */
34 <        float           *prow;          /* current price row */
35 < } PRICEMAT;                     /* sorted pricing matrix */
30 > /* Compute average DSF value at the given radius from central vector */
31 > static double
32 > eval_DSFsurround(const RBFNODE *rbf, const FVECT outvec, const double rad)
33 > {
34 >        const int       ninc = 12;
35 >        const double    phinc = 2.*M_PI/ninc;
36 >        double          sum = 0;
37 >        int             n = 0;
38 >        FVECT           tvec;
39 >        int             i;
40 >                                                /* compute initial vector */
41 >        if (output_orient*outvec[2] >= 1.-FTINY) {
42 >                tvec[0] = tvec[2] = 0;
43 >                tvec[1] = 1;
44 >        } else {
45 >                tvec[0] = tvec[1] = 0;
46 >                tvec[2] = 1;
47 >        }
48 >        geodesic(tvec, outvec, tvec, rad, GEOD_RAD);
49 >                                                /* average surrounding DSF */
50 >        for (i = 0; i < ninc; i++) {
51 >                if (i) spinvector(tvec, tvec, outvec, phinc);
52 >                if (tvec[2] > 0 ^ output_orient > 0)
53 >                        continue;
54 >                sum += eval_rbfrep(rbf, tvec) * output_orient*tvec[2];
55 >                ++n;
56 >        }
57 >        if (n < 2)                              /* should never happen! */
58 >                return(sum);
59 >        return(sum/(double)n);
60 > }
61  
62 < #define pricerow(p,i)   ((p)->price + (i)*(p)->ncols)
63 < #define psortrow(p,i)   ((p)->sord + (i)*(p)->ncols)
62 > /* Estimate single-lobe radius for DSF at the given outgoing angle */
63 > static double
64 > est_DSFrad(const RBFNODE *rbf, const FVECT outvec)
65 > {
66 >        const double    rad_epsilon = 0.03;
67 >        const double    DSFtarget = 0.60653066 * eval_rbfrep(rbf,outvec)
68 >                                                * output_orient*outvec[2];
69 >        double          inside_rad = rad_epsilon;
70 >        double          outside_rad = 0.5;
71 >        double          DSFinside = eval_DSFsurround(rbf, outvec, inside_rad);
72 >        double          DSFoutside = eval_DSFsurround(rbf, outvec, outside_rad);
73 > #define interp_rad      inside_rad + (outside_rad-inside_rad) * \
74 >                                (DSFtarget-DSFinside) / (DSFoutside-DSFinside)
75 >                                                /* interpolation search */
76 >        while (outside_rad-inside_rad > rad_epsilon) {
77 >                double  test_rad = interp_rad;
78 >                double  DSFtest = eval_DSFsurround(rbf, outvec, test_rad);
79 >                if (DSFtarget < DSFtest) {
80 >                        inside_rad = test_rad;
81 >                        DSFinside = DSFtest;
82 >                } else {
83 >                        outside_rad = test_rad;
84 >                        DSFoutside = DSFtest;
85 >                }
86 >        }
87 >        return(interp_rad);
88 > #undef interp_rad
89 > }
90  
91 + /* Compute average BSDF peak from current DSF's */
92 + static void
93 + comp_bsdf_spec(void)
94 + {
95 +        double          peak_sum = 0;
96 +        double          rad_sum = 0;
97 +        int             n = 0;
98 +        RBFNODE         *rbf;
99 +        FVECT           sdv;
100 +
101 +        if (dsf_list == NULL) {
102 +                bsdf_spec_peak = 0;
103 +                bsdf_spec_crad = 0;
104 +                return;
105 +        }
106 +        for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) {
107 +                sdv[0] = -rbf->invec[0];
108 +                sdv[1] = -rbf->invec[1];
109 +                sdv[2] = rbf->invec[2]*(2*(input_orient==output_orient) - 1);
110 +                peak_sum += eval_rbfrep(rbf, sdv);
111 +                rad_sum += est_DSFrad(rbf, sdv);
112 +                ++n;
113 +        }
114 +        bsdf_spec_peak = peak_sum/(double)n;
115 +        bsdf_spec_crad = ANG2R( rad_sum/(double)n );
116 + }
117 +
118   /* Create a new migration holder (sharing memory for multiprocessing) */
119   static MIGRATION *
120   new_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
# Line 135 | Line 217 | run_subprocess(void)
217  
218   #endif  /* ! _WIN32 */
219  
220 < /* Comparison routine needed for sorting price row */
139 < static int
140 < msrt_cmp(void *b, const void *p1, const void *p2)
141 < {
142 <        PRICEMAT        *pm = (PRICEMAT *)b;
143 <        float           c1 = pm->prow[*(const short *)p1];
144 <        float           c2 = pm->prow[*(const short *)p2];
145 <
146 <        if (c1 > c2) return(1);
147 <        if (c1 < c2) return(-1);
148 <        return(0);
149 < }
150 <
151 < /* Compute (and allocate) migration price matrix for optimization */
220 > /* Compute normalized distribution scattering functions for comparison */
221   static void
222 < price_routes(PRICEMAT *pm, const RBFNODE *from_rbf, const RBFNODE *to_rbf)
222 > compute_nDSFs(const RBFNODE *rbf0, const RBFNODE *rbf1)
223   {
224 <        FVECT   *vto = (FVECT *)malloc(sizeof(FVECT) * to_rbf->nrbf);
225 <        int     i, j;
224 >        const double    nf0 = (GRIDRES*GRIDRES) / rbf0->vtotal;
225 >        const double    nf1 = (GRIDRES*GRIDRES) / rbf1->vtotal;
226 >        int             x, y;
227 >        FVECT           dv;
228  
229 <        pm->nrows = from_rbf->nrbf;
230 <        pm->ncols = to_rbf->nrbf;
231 <        pm->price = (float *)malloc(sizeof(float) * pm->nrows*pm->ncols);
232 <        pm->sord = (short *)malloc(sizeof(short) * pm->nrows*pm->ncols);
233 <        
163 <        if ((pm->price == NULL) | (pm->sord == NULL) | (vto == NULL)) {
164 <                fprintf(stderr, "%s: Out of memory in migration_costs()\n",
165 <                                progname);
166 <                exit(1);
167 <        }
168 <        for (j = to_rbf->nrbf; j--; )           /* save repetitive ops. */
169 <                ovec_from_pos(vto[j], to_rbf->rbfa[j].gx, to_rbf->rbfa[j].gy);
170 <
171 <        for (i = from_rbf->nrbf; i--; ) {
172 <            const double        from_ang = R2ANG(from_rbf->rbfa[i].crad);
173 <            FVECT               vfrom;
174 <            short               *srow;
175 <            ovec_from_pos(vfrom, from_rbf->rbfa[i].gx, from_rbf->rbfa[i].gy);
176 <            pm->prow = pricerow(pm,i);
177 <            srow = psortrow(pm,i);
178 <            for (j = to_rbf->nrbf; j--; ) {
179 <                double          dprod = DOT(vfrom, vto[j]);
180 <                pm->prow[j] = ((dprod >= 1.) ? .0 : acos(dprod)) +
181 <                                fabs(R2ANG(to_rbf->rbfa[j].crad) - from_ang);
182 <                srow[j] = j;
229 >        for (x = GRIDRES; x--; )
230 >            for (y = GRIDRES; y--; ) {
231 >                ovec_from_pos(dv, x, y);        /* cube root (brightness) */
232 >                dsf_grid[x][y].val[0] = pow(nf0*eval_rbfrep(rbf0, dv), .3333);
233 >                dsf_grid[x][y].val[1] = pow(nf1*eval_rbfrep(rbf1, dv), .3333);
234              }
235 <            qsort_r(srow, pm->ncols, sizeof(short), pm, &msrt_cmp);
185 <        }
186 <        free(vto);
187 < }
235 > }      
236  
237 < /* Free price matrix */
190 < static void
191 < free_routes(PRICEMAT *pm)
192 < {
193 <        free(pm->price); pm->price = NULL;
194 <        free(pm->sord); pm->sord = NULL;
195 < }
196 <
197 < /* Compute minimum (optimistic) cost for moving the given source material */
237 > /* Compute neighborhood distance-squared (dissimilarity) */
238   static double
239 < min_cost(double amt2move, const double *avail, const PRICEMAT *pm, int s)
239 > neighborhood_dist2(int x0, int y0, int x1, int y1)
240   {
241 <        const short     *srow = psortrow(pm,s);
242 <        const float     *prow = pricerow(pm,s);
243 <        double          total_cost = 0;
244 <        int             j;
245 <                                                /* move cheapest first */
246 <        for (j = 0; (j < pm->ncols) & (amt2move > FTINY); j++) {
247 <                int     d = srow[j];
248 <                double  amt = (amt2move < avail[d]) ? amt2move : avail[d];
249 <
250 <                total_cost += amt * prow[d];
211 <                amt2move -= amt;
241 >        int     rad = GRIDRES>>5;
242 >        double  sum2 = 0.;
243 >        double  d;
244 >        int     p[4];
245 >        int     i, j;
246 >                                                /* check radius */
247 >        p[0] = x0; p[1] = y0; p[2] = x1; p[3] = y1;
248 >        for (i = 4; i--; ) {
249 >                if (p[i] < rad) rad = p[i];
250 >                if (GRIDRES-1-p[i] < rad) rad = GRIDRES-1-p[i];
251          }
252 <        return(total_cost);
252 >        for (i = -rad; i <= rad; i++)
253 >            for (j = -rad; j <= rad; j++) {
254 >                d = dsf_grid[x0+i][y0+j].val[0] -
255 >                        dsf_grid[x1+i][y1+j].val[1];
256 >                sum2 += d*d;
257 >            }
258 >        return(sum2 / (4*rad*(rad+1) + 1));
259   }
260  
261 < /* Compare entries by moving price */
262 < static int
263 < rmovcmp(void *b, const void *p1, const void *p2)
261 > /* Compute distance between two RBF lobes */
262 > double
263 > lobe_distance(RBFVAL *rbf1, RBFVAL *rbf2)
264   {
265 <        PRICEMAT        *pm = (PRICEMAT *)b;
266 <        const short     *ij1 = (const short *)p1;
267 <        const short     *ij2 = (const short *)p2;
268 <        float           price_diff;
269 <
270 <        if (ij1[1] < 0) return(ij2[1] >= 0);
271 <        if (ij2[1] < 0) return(-1);
272 <        price_diff = pricerow(pm,ij1[0])[ij1[1]] - pricerow(pm,ij2[0])[ij2[1]];
273 <        if (price_diff > 0) return(1);
274 <        if (price_diff < 0) return(-1);
275 <        return(0);
265 >        FVECT   vfrom, vto;
266 >        double  d, res;
267 >                                        /* quadratic cost function */
268 >        ovec_from_pos(vfrom, rbf1->gx, rbf1->gy);
269 >        ovec_from_pos(vto, rbf2->gx, rbf2->gy);
270 >        d = Acos(DOT(vfrom, vto));
271 >        res = d*d;
272 >        d = R2ANG(rbf2->crad) - R2ANG(rbf1->crad);
273 >        res += d*d;
274 >                                        /* neighborhood difference */
275 >        res += NEIGH_FACT2 * neighborhood_dist2( rbf1->gx, rbf1->gy,
276 >                                                rbf2->gx, rbf2->gy );
277 >        return(res);
278   }
279  
233 /* Take a step in migration by choosing reasonable bucket to transfer */
234 static double
235 migration_step(MIGRATION *mig, double *src_rem, double *dst_rem, PRICEMAT *pm)
236 {
237        const int       max2check = 100;
238        const double    maxamt = 1./(double)pm->ncols;
239        const double    minamt = maxamt*1e-4;
240        double          *src_cost;
241        short           (*rord)[2];
242        struct {
243                int     s, d;   /* source and destination */
244                double  price;  /* price estimate per amount moved */
245                double  amt;    /* amount we can move */
246        } cur, best;
247        int             r2check, i, ri;
248        /*
249         * Check cheapest available routes only -- a higher adjusted
250         * destination price implies that another source is closer, so
251         * we can hold off considering more expensive options until
252         * some other (hopefully better) moves have been made.
253         */
254                                                /* most promising row order */
255        rord = (short (*)[2])malloc(sizeof(short)*2*pm->nrows);
256        if (rord == NULL)
257                goto memerr;
258        for (ri = pm->nrows; ri--; ) {
259            rord[ri][0] = ri;
260            rord[ri][1] = -1;
261            if (src_rem[ri] <= minamt)          /* enough source material? */
262                    continue;
263            for (i = 0; i < pm->ncols; i++)
264                if (dst_rem[ rord[ri][1] = psortrow(pm,ri)[i] ] > minamt)
265                        break;
266            if (i >= pm->ncols) {               /* moved all we can? */
267                free(rord);
268                return(.0);
269            }
270        }
271        if (pm->nrows > max2check)              /* sort if too many sources */
272                qsort_r(rord, pm->nrows, sizeof(short)*2, pm, &rmovcmp);
273                                                /* allocate cost array */
274        src_cost = (double *)malloc(sizeof(double)*pm->nrows);
275        if (src_cost == NULL)
276                goto memerr;
277        for (i = pm->nrows; i--; )              /* starting costs for diff. */
278                src_cost[i] = min_cost(src_rem[i], dst_rem, pm, i);
279                                                /* find best source & dest. */
280        best.s = best.d = -1; best.price = FHUGE; best.amt = 0;
281        if ((r2check = pm->nrows) > max2check)
282                r2check = max2check;            /* put a limit on search */
283        for (ri = 0; ri < r2check; ri++) {      /* check each source row */
284            double      cost_others = 0;
285            cur.s = rord[ri][0];
286            if ((cur.d = rord[ri][1]) < 0 ||
287                        (cur.price = pricerow(pm,cur.s)[cur.d]) >= best.price) {
288                if (pm->nrows > max2check) break;       /* sorted end */
289                continue;                       /* else skip this one */
290            }
291            cur.amt = (src_rem[cur.s] < dst_rem[cur.d]) ?
292                                src_rem[cur.s] : dst_rem[cur.d];
293                                                /* don't just leave smidgen */
294            if (cur.amt > maxamt*1.02) cur.amt = maxamt;
295            dst_rem[cur.d] -= cur.amt;          /* add up opportunity costs */
296            for (i = pm->nrows; i--; )
297                if (i != cur.s)
298                    cost_others += min_cost(src_rem[i], dst_rem, pm, i)
299                                        - src_cost[i];
300            dst_rem[cur.d] += cur.amt;          /* undo trial move */
301            cur.price += cost_others/cur.amt;   /* adjust effective price */
302            if (cur.price < best.price)         /* are we better than best? */
303                best = cur;
304        }
305        free(src_cost);                         /* clean up */
306        free(rord);
307        if ((best.s < 0) | (best.d < 0))        /* nothing left to move? */
308                return(.0);
309                                                /* else make the actual move */
310        mtx_coef(mig,best.s,best.d) += best.amt;
311        src_rem[best.s] -= best.amt;
312        dst_rem[best.d] -= best.amt;
313        return(best.amt);
314 memerr:
315        fprintf(stderr, "%s: Out of memory in migration_step()\n", progname);
316        exit(1);
317 }
280  
281   /* Compute and insert migration along directed edge (may fork child) */
282   static MIGRATION *
283   create_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
284   {
323        const double    end_thresh = 5e-6;
324        PRICEMAT        pmtx;
285          MIGRATION       *newmig;
326        double          *src_rem, *dst_rem;
327        double          total_rem = 1., move_amt;
286          int             i, j;
287                                                  /* check if exists already */
288          for (newmig = from_rbf->ejl; newmig != NULL;
# Line 333 | Line 291 | create_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
291                          return(NULL);
292                                                  /* else allocate */
293   #ifdef DEBUG
294 <        fprintf(stderr, "Building path from (theta,phi) (%.0f,%.0f) ",
294 >        fprintf(stderr, "Building path from (theta,phi) (%.1f,%.1f) ",
295                          get_theta180(from_rbf->invec),
296                          get_phi360(from_rbf->invec));
297 <        fprintf(stderr, "to (%.0f,%.0f) with %d x %d matrix\n",
297 >        fprintf(stderr, "to (%.1f,%.1f) with %d x %d matrix\n",
298                          get_theta180(to_rbf->invec),
299                          get_phi360(to_rbf->invec),
300                          from_rbf->nrbf, to_rbf->nrbf);
# Line 344 | Line 302 | create_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
302          newmig = new_migration(from_rbf, to_rbf);
303          if (run_subprocess())
304                  return(newmig);                 /* child continues */
347        price_routes(&pmtx, from_rbf, to_rbf);
348        src_rem = (double *)malloc(sizeof(double)*from_rbf->nrbf);
349        dst_rem = (double *)malloc(sizeof(double)*to_rbf->nrbf);
350        if ((src_rem == NULL) | (dst_rem == NULL)) {
351                fprintf(stderr, "%s: Out of memory in create_migration()\n",
352                                progname);
353                exit(1);
354        }
355                                                /* starting quantities */
356        memset(newmig->mtx, 0, sizeof(float)*from_rbf->nrbf*to_rbf->nrbf);
357        for (i = from_rbf->nrbf; i--; )
358                src_rem[i] = rbf_volume(&from_rbf->rbfa[i]) / from_rbf->vtotal;
359        for (j = to_rbf->nrbf; j--; )
360                dst_rem[j] = rbf_volume(&to_rbf->rbfa[j]) / to_rbf->vtotal;
305  
306 <        do {                                    /* move a bit at a time */
307 <                move_amt = migration_step(newmig, src_rem, dst_rem, &pmtx);
308 <                total_rem -= move_amt;
365 <        } while ((total_rem > end_thresh) & (move_amt > 0));
306 >                                                /* compute transport plan */
307 >        compute_nDSFs(from_rbf, to_rbf);
308 >        plan_transport(newmig);
309  
310          for (i = from_rbf->nrbf; i--; ) {       /* normalize final matrix */
311              double      nf = rbf_volume(&from_rbf->rbfa[i]);
# Line 372 | Line 315 | create_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
315                  mtx_coef(newmig,i,j) *= nf;     /* row now sums to 1.0 */
316          }
317          end_subprocess();                       /* exit here if subprocess */
375        free_routes(&pmtx);                     /* free working arrays */
376        free(src_rem);
377        free(dst_rem);
318          return(newmig);
319   }
320  
# Line 404 | Line 344 | overlaps_tri(const RBFNODE *bv0, const RBFNODE *bv1, c
344          return(vother[im_rev] != NULL);
345   }
346  
347 < /* Find context hull vertex to complete triangle (oriented call) */
347 > /* Find convex hull vertex to complete triangle (oriented call) */
348   static RBFNODE *
349   find_chull_vert(const RBFNODE *rbf0, const RBFNODE *rbf1)
350   {
# Line 425 | Line 365 | find_chull_vert(const RBFNODE *rbf0, const RBFNODE *rb
365                  if (DOT(vp, vmid) <= FTINY)
366                          continue;               /* wrong orientation */
367                  area2 = .25*DOT(vp,vp);
368 <                VSUB(vp, rbf->invec, rbf0->invec);
368 >                VSUB(vp, rbf->invec, vmid);
369                  dprod = -DOT(vp, vejn);
370                  VSUM(vp, vp, vejn, dprod);      /* above guarantees non-zero */
371                  dprod = DOT(vp, vmid) / VLEN(vp);
# Line 464 | Line 404 | mesh_from_edge(MIGRATION *edge)
404                                  ej1 = create_migration(tvert[0], edge->rbfv[1]);
405                          mesh_from_edge(ej0);
406                          mesh_from_edge(ej1);
407 +                        return;
408                  }
409 <        } else if (tvert[1] == NULL) {          /* grow mesh on left */
409 >        }
410 >        if (tvert[1] == NULL) {                 /* grow mesh on left */
411                  tvert[1] = find_chull_vert(edge->rbfv[1], edge->rbfv[0]);
412                  if (tvert[1] != NULL) {
413                          if (tvert[1]->ord > edge->rbfv[0]->ord)
# Line 481 | Line 423 | mesh_from_edge(MIGRATION *edge)
423                  }
424          }
425   }
426 +
427 + /* Add normal direction if missing */
428 + static void
429 + check_normal_incidence(void)
430 + {
431 +        static FVECT            norm_vec = {.0, .0, 1.};
432 +        const int               saved_nprocs = nprocs;
433 +        RBFNODE                 *near_rbf, *mir_rbf, *rbf;
434 +        double                  bestd;
435 +        int                     n;
436 +
437 +        if (dsf_list == NULL)
438 +                return;                         /* XXX should be error? */
439 +        near_rbf = dsf_list;
440 +        bestd = input_orient*near_rbf->invec[2];
441 +        if (single_plane_incident) {            /* ordered plane incidence? */
442 +                if (bestd >= 1.-2.*FTINY)
443 +                        return;                 /* already have normal */
444 +        } else {
445 +                switch (inp_coverage) {
446 +                case INP_QUAD1:
447 +                case INP_QUAD2:
448 +                case INP_QUAD3:
449 +                case INP_QUAD4:
450 +                        break;                  /* quadrilateral symmetry? */
451 +                default:
452 +                        return;                 /* else we can interpolate */
453 +                }
454 +                for (rbf = near_rbf->next; rbf != NULL; rbf = rbf->next) {
455 +                        const double    d = input_orient*rbf->invec[2];
456 +                        if (d >= 1.-2.*FTINY)
457 +                                return;         /* seems we have normal */
458 +                        if (d > bestd) {
459 +                                near_rbf = rbf;
460 +                                bestd = d;
461 +                        }
462 +                }
463 +        }
464 +        if (mig_list != NULL) {                 /* need to be called first */
465 +                fprintf(stderr, "%s: Late call to check_normal_incidence()\n",
466 +                                progname);
467 +                exit(1);
468 +        }
469 + #ifdef DEBUG
470 +        fprintf(stderr, "Interpolating normal incidence by mirroring (%.1f,%.1f)\n",
471 +                        get_theta180(near_rbf->invec), get_phi360(near_rbf->invec));
472 + #endif
473 +                                                /* mirror nearest incidence */
474 +        n = sizeof(RBFNODE) + sizeof(RBFVAL)*(near_rbf->nrbf-1);
475 +        mir_rbf = (RBFNODE *)malloc(n);
476 +        if (mir_rbf == NULL)
477 +                goto memerr;
478 +        memcpy(mir_rbf, near_rbf, n);
479 +        mir_rbf->ord = near_rbf->ord - 1;       /* not used, I think */
480 +        mir_rbf->next = NULL;
481 +        mir_rbf->ejl = NULL;
482 +        rev_rbf_symmetry(mir_rbf, MIRROR_X|MIRROR_Y);
483 +        nprocs = 1;                             /* compute migration matrix */
484 +        if (create_migration(mir_rbf, near_rbf) == NULL)
485 +                exit(1);                        /* XXX should never happen! */
486 +        norm_vec[2] = input_orient;             /* interpolate normal dist. */
487 +        rbf = e_advect_rbf(mig_list, norm_vec, 0);
488 +        nprocs = saved_nprocs;                  /* final clean-up */
489 +        free(mir_rbf);
490 +        free(mig_list);
491 +        mig_list = near_rbf->ejl = NULL;
492 +        insert_dsf(rbf);                        /* insert interpolated normal */
493 +        return;
494 + memerr:
495 +        fprintf(stderr, "%s: Out of memory in check_normal_incidence()\n",
496 +                                progname);
497 +        exit(1);
498 + }
499          
500   /* Build our triangle mesh from recorded RBFs */
501   void
# Line 489 | Line 504 | build_mesh(void)
504          double          best2 = M_PI*M_PI;
505          RBFNODE         *shrt_edj[2];
506          RBFNODE         *rbf0, *rbf1;
507 +                                                /* average specular peak */
508 +        comp_bsdf_spec();
509 +                                                /* add normal if needed */
510 +        check_normal_incidence();
511                                                  /* check if isotropic */
512          if (single_plane_incident) {
513                  for (rbf0 = dsf_list; rbf0 != NULL; rbf0 = rbf0->next)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines