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.18 by greg, Thu Mar 6 00:40:37 2014 UTC vs.
Revision 2.38 by greg, Tue May 16 20:41:03 2017 UTC

# Line 7 | Line 7 | static const char RCSid[] = "$Id$";
7   *      G. Ward
8   */
9  
10 < #ifndef _WIN32
10 > #if !defined(_WIN32) && !defined(_WIN64)
11   #include <unistd.h>
12   #include <sys/wait.h>
13   #include <sys/mman.h>
# 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) * COSF(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 >                                                        COSF(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 >                                                /* Newton's method (sort of) */
76 >        do {
77 >                double  test_rad = interp_rad;
78 >                double  DSFtest;
79 >                if (test_rad >= outside_rad)
80 >                        return(test_rad);
81 >                if (test_rad <= inside_rad)
82 >                        return(test_rad*(test_rad>0));
83 >                DSFtest = eval_DSFsurround(rbf, outvec, test_rad);
84 >                if (DSFtest > DSFtarget) {
85 >                        inside_rad = test_rad;
86 >                        DSFinside = DSFtest;
87 >                } else {
88 >                        outside_rad = test_rad;
89 >                        DSFoutside = DSFtest;
90 >                }
91 >                if (DSFoutside >= DSFinside)
92 >                        return(test_rad);
93 >        } while (outside_rad-inside_rad > rad_epsilon);
94 >        return(interp_rad);
95 > #undef interp_rad
96 > }
97  
98 + static int
99 + dbl_cmp(const void *p1, const void *p2)
100 + {
101 +        double  d1 = *(const double *)p1;
102 +        double  d2 = *(const double *)p2;
103 +
104 +        if (d1 > d2) return(1);
105 +        if (d1 < d2) return(-1);
106 +        return(0);
107 + }
108 +
109 + /* Conservative estimate of average BSDF value from current DSF's */
110 + static void
111 + comp_bsdf_spec(void)
112 + {
113 +        double          vmod_sum = 0;
114 +        double          rad_sum = 0;
115 +        int             n = 0;
116 +        double          *cost_list = NULL;
117 +        double          max_cost = 1.;
118 +        RBFNODE         *rbf;
119 +        FVECT           sdv;
120 +                                                /* sort by incident altitude */
121 +        for (rbf = dsf_list; rbf != NULL; rbf = rbf->next)
122 +                n++;
123 +        if (n >= 10)
124 +                cost_list = (double *)malloc(sizeof(double)*n);
125 +        if (cost_list == NULL) {
126 +                bsdf_spec_val = 0;
127 +                bsdf_spec_rad = 0;
128 +                return;
129 +        }
130 +        n = 0;
131 +        for (rbf = dsf_list; rbf != NULL; rbf = rbf->next)
132 +                cost_list[n++] = rbf->invec[2]*input_orient;
133 +        qsort(cost_list, n, sizeof(double), dbl_cmp);
134 +        max_cost = cost_list[(n+3)/4];          /* accept 25% nearest grazing */
135 +        free(cost_list);
136 +        n = 0;
137 +        for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) {
138 +                double  this_rad, cosfact, vest;
139 +                if (rbf->invec[2]*input_orient > max_cost)
140 +                        continue;
141 +                sdv[0] = -rbf->invec[0];
142 +                sdv[1] = -rbf->invec[1];
143 +                sdv[2] = rbf->invec[2]*(2*(input_orient==output_orient) - 1);
144 +                cosfact = COSF(sdv[2]);
145 +                this_rad = est_DSFrad(rbf, sdv);
146 +                vest = eval_rbfrep(rbf, sdv) * cosfact *
147 +                                (2.*M_PI) * this_rad*this_rad;
148 +                if (vest > rbf->vtotal)         /* don't over-estimate energy */
149 +                        vest = rbf->vtotal;
150 +                vmod_sum += vest / cosfact;     /* remove cosine factor */
151 +                rad_sum += this_rad;
152 +                ++n;
153 +        }
154 +        bsdf_spec_rad = rad_sum/(double)n;
155 +        bsdf_spec_val = vmod_sum/(2.*M_PI*n*bsdf_spec_rad*bsdf_spec_rad);
156 + }
157 +
158   /* Create a new migration holder (sharing memory for multiprocessing) */
159   static MIGRATION *
160   new_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
# Line 40 | Line 162 | new_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
162          size_t          memlen = sizeof(MIGRATION) +
163                                  sizeof(float)*(from_rbf->nrbf*to_rbf->nrbf - 1);
164          MIGRATION       *newmig;
165 < #ifdef _WIN32
165 > #if defined(_WIN32) || defined(_WIN64)
166          if (nprocs > 1)
167                  fprintf(stderr, "%s: warning - multiprocessing not supported\n",
168                                  progname);
# Line 71 | Line 193 | new_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
193          return(mig_list = newmig);
194   }
195  
196 < #ifdef _WIN32
196 > #if defined(_WIN32) || defined(_WIN64)
197   #define await_children(n)       (void)(n)
198   #define run_subprocess()        0
199   #define end_subprocess()        (void)0
# Line 135 | Line 257 | run_subprocess(void)
257  
258   #endif  /* ! _WIN32 */
259  
260 < /* 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 */
260 > /* Compute normalized distribution scattering functions for comparison */
261   static void
262 < price_routes(PRICEMAT *pm, const RBFNODE *from_rbf, const RBFNODE *to_rbf)
262 > compute_nDSFs(const RBFNODE *rbf0, const RBFNODE *rbf1)
263   {
264 <        FVECT   *vto = (FVECT *)malloc(sizeof(FVECT) * to_rbf->nrbf);
265 <        int     i, j;
264 >        const double    nf0 = (GRIDRES*GRIDRES) / rbf0->vtotal;
265 >        const double    nf1 = (GRIDRES*GRIDRES) / rbf1->vtotal;
266 >        int             x, y;
267 >        FVECT           dv;
268  
269 <        pm->nrows = from_rbf->nrbf;
270 <        pm->ncols = to_rbf->nrbf;
271 <        pm->price = (float *)malloc(sizeof(float) * pm->nrows*pm->ncols);
272 <        pm->sord = (short *)malloc(sizeof(short) * pm->nrows*pm->ncols);
273 <        
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          d;              /* quadratic cost function */
180 <                d = Acos(DOT(vfrom, vto[j]));
181 <                pm->prow[j] = d*d;
182 <                d = R2ANG(to_rbf->rbfa[j].crad) - from_ang;
183 <                pm->prow[j] += d*d;    
184 <                srow[j] = j;
269 >        for (x = GRIDRES; x--; )
270 >            for (y = GRIDRES; y--; ) {
271 >                ovec_from_pos(dv, x, y);        /* cube root (brightness) */
272 >                dsf_grid[x][y].val[0] = pow(nf0*eval_rbfrep(rbf0, dv), .3333);
273 >                dsf_grid[x][y].val[1] = pow(nf1*eval_rbfrep(rbf1, dv), .3333);
274              }
275 <            qsort_r(srow, pm->ncols, sizeof(short), pm, &msrt_cmp);
187 <        }
188 <        free(vto);
189 < }
275 > }      
276  
277 < /* Free price matrix */
192 < static void
193 < free_routes(PRICEMAT *pm)
194 < {
195 <        free(pm->price); pm->price = NULL;
196 <        free(pm->sord); pm->sord = NULL;
197 < }
198 <
199 < /* Compute minimum (optimistic) cost for moving the given source material */
277 > /* Compute neighborhood distance-squared (dissimilarity) */
278   static double
279 < min_cost(double amt2move, const double *avail, const PRICEMAT *pm, int s)
279 > neighborhood_dist2(int x0, int y0, int x1, int y1)
280   {
281 <        const short     *srow = psortrow(pm,s);
282 <        const float     *prow = pricerow(pm,s);
283 <        double          total_cost = 0;
284 <        int             j;
285 <                                                /* move cheapest first */
286 <        for (j = 0; (j < pm->ncols) & (amt2move > FTINY); j++) {
287 <                int     d = srow[j];
288 <                double  amt = (amt2move < avail[d]) ? amt2move : avail[d];
289 <
290 <                total_cost += amt * prow[d];
213 <                amt2move -= amt;
281 >        int     rad = GRIDRES>>5;
282 >        double  sum2 = 0.;
283 >        double  d;
284 >        int     p[4];
285 >        int     i, j;
286 >                                                /* check radius */
287 >        p[0] = x0; p[1] = y0; p[2] = x1; p[3] = y1;
288 >        for (i = 4; i--; ) {
289 >                if (p[i] < rad) rad = p[i];
290 >                if (GRIDRES-1-p[i] < rad) rad = GRIDRES-1-p[i];
291          }
292 <        return(total_cost);
292 >        for (i = -rad; i <= rad; i++)
293 >            for (j = -rad; j <= rad; j++) {
294 >                d = dsf_grid[x0+i][y0+j].val[0] -
295 >                        dsf_grid[x1+i][y1+j].val[1];
296 >                sum2 += d*d;
297 >            }
298 >        return(sum2 / (4*rad*(rad+1) + 1));
299   }
300  
301 < typedef struct {
302 <        short   s, d;           /* source and destination */
303 <        float   dc;             /* discount to push inventory */
221 < } ROWSENT;              /* row sort entry */
222 <
223 < /* Compare entries by discounted moving price */
224 < static int
225 < rmovcmp(void *b, const void *p1, const void *p2)
301 > /* Compute distance between two RBF lobes */
302 > double
303 > lobe_distance(RBFVAL *rbf1, RBFVAL *rbf2)
304   {
305 <        PRICEMAT        *pm = (PRICEMAT *)b;
306 <        const ROWSENT   *re1 = (const ROWSENT *)p1;
307 <        const ROWSENT   *re2 = (const ROWSENT *)p2;
308 <        double          price_diff;
309 <
310 <        if (re1->d < 0) return(re2->d >= 0);
311 <        if (re2->d < 0) return(-1);
312 <        price_diff = re1->dc*pricerow(pm,re1->s)[re1->d] -
313 <                        re2->dc*pricerow(pm,re2->s)[re2->d];
314 <        if (price_diff > 0) return(1);
315 <        if (price_diff < 0) return(-1);
316 <        return(0);
305 >        FVECT   vfrom, vto;
306 >        double  d, res;
307 >                                        /* quadratic cost function */
308 >        ovec_from_pos(vfrom, rbf1->gx, rbf1->gy);
309 >        ovec_from_pos(vto, rbf2->gx, rbf2->gy);
310 >        d = Acos(DOT(vfrom, vto));
311 >        res = d*d;
312 >        d = R2ANG(rbf2->crad) - R2ANG(rbf1->crad);
313 >        res += d*d;
314 >                                        /* neighborhood difference */
315 >        res += NEIGH_FACT2 * neighborhood_dist2( rbf1->gx, rbf1->gy,
316 >                                                rbf2->gx, rbf2->gy );
317 >        return(res);
318   }
319  
241 /* Take a step in migration by choosing reasonable bucket to transfer */
242 static double
243 migration_step(MIGRATION *mig, double *src_rem, double *dst_rem, PRICEMAT *pm)
244 {
245        const int       max2check = 100;
246        const double    maxamt = 1./(double)pm->ncols;
247        const double    minamt = maxamt*1e-4;
248        double          *src_cost;
249        ROWSENT         *rord;
250        struct {
251                int     s, d;   /* source and destination */
252                double  price;  /* cost per amount moved */
253                double  amt;    /* amount we can move */
254        } cur, best;
255        int             r2check, i, ri;
256        /*
257         * Check cheapest available routes only -- a higher adjusted
258         * destination price implies that another source is closer, so
259         * we can hold off considering more expensive options until
260         * some other (hopefully better) moves have been made.
261         * A discount based on source remaining is supposed to prioritize
262         * movement from large lobes, but it doesn't seem to do much,
263         * so we have it set to 1.0 at the moment.
264         */
265 #define discount(qr)    1.0
266                                                /* most promising row order */
267        rord = (ROWSENT *)malloc(sizeof(ROWSENT)*pm->nrows);
268        if (rord == NULL)
269                goto memerr;
270        for (ri = pm->nrows; ri--; ) {
271            rord[ri].s = ri;
272            rord[ri].d = -1;
273            rord[ri].dc = 1.f;
274            if (src_rem[ri] <= minamt)          /* enough source material? */
275                    continue;
276            for (i = 0; i < pm->ncols; i++)
277                if (dst_rem[ rord[ri].d = psortrow(pm,ri)[i] ] > minamt)
278                        break;
279            if (i >= pm->ncols) {               /* moved all we can? */
280                free(rord);
281                return(.0);
282            }
283            rord[ri].dc = discount(src_rem[ri]);
284        }
285        if (pm->nrows > max2check)              /* sort if too many sources */
286                qsort_r(rord, pm->nrows, sizeof(ROWSENT), pm, &rmovcmp);
287                                                /* allocate cost array */
288        src_cost = (double *)malloc(sizeof(double)*pm->nrows);
289        if (src_cost == NULL)
290                goto memerr;
291        for (i = pm->nrows; i--; )              /* starting costs for diff. */
292                src_cost[i] = min_cost(src_rem[i], dst_rem, pm, i);
293                                                /* find best source & dest. */
294        best.s = best.d = -1; best.price = FHUGE; best.amt = 0;
295        if ((r2check = pm->nrows) > max2check)
296                r2check = max2check;            /* put a limit on search */
297        for (ri = 0; ri < r2check; ri++) {      /* check each source row */
298            double      cost_others = 0;
299            cur.s = rord[ri].s;
300            if ((cur.d = rord[ri].d) < 0 ||
301                        rord[ri].dc*pricerow(pm,cur.s)[cur.d] >= best.price) {
302                if (pm->nrows > max2check) break;       /* sorted end */
303                continue;                       /* else skip this one */
304            }
305            cur.amt = (src_rem[cur.s] < dst_rem[cur.d]) ?
306                                src_rem[cur.s] : dst_rem[cur.d];
307                                                /* don't just leave smidgen */
308            if (cur.amt > maxamt*1.02) cur.amt = maxamt;
309            dst_rem[cur.d] -= cur.amt;          /* add up opportunity costs */
310            for (i = pm->nrows; i--; )
311                if (i != cur.s)
312                    cost_others += min_cost(src_rem[i], dst_rem, pm, i)
313                                        - src_cost[i];
314            dst_rem[cur.d] += cur.amt;          /* undo trial move */
315                                                /* discount effective price */
316            cur.price = ( pricerow(pm,cur.s)[cur.d] + cost_others/cur.amt ) *
317                                        rord[ri].dc;
318            if (cur.price < best.price)         /* are we better than best? */
319                best = cur;
320        }
321        free(src_cost);                         /* clean up */
322        free(rord);
323        if ((best.s < 0) | (best.d < 0))        /* nothing left to move? */
324                return(.0);
325                                                /* else make the actual move */
326        mtx_coef(mig,best.s,best.d) += best.amt;
327        src_rem[best.s] -= best.amt;
328        dst_rem[best.d] -= best.amt;
329        return(best.amt);
330 memerr:
331        fprintf(stderr, "%s: Out of memory in migration_step()\n", progname);
332        exit(1);
333 #undef discount
334 }
320  
321   /* Compute and insert migration along directed edge (may fork child) */
322   static MIGRATION *
323   create_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
324   {
340        const double    end_thresh = 5e-6;
341        PRICEMAT        pmtx;
325          MIGRATION       *newmig;
343        double          *src_rem, *dst_rem;
344        double          total_rem = 1., move_amt;
326          int             i, j;
327                                                  /* check if exists already */
328          for (newmig = from_rbf->ejl; newmig != NULL;
# Line 361 | Line 342 | create_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
342          newmig = new_migration(from_rbf, to_rbf);
343          if (run_subprocess())
344                  return(newmig);                 /* child continues */
364        price_routes(&pmtx, from_rbf, to_rbf);
365        src_rem = (double *)malloc(sizeof(double)*from_rbf->nrbf);
366        dst_rem = (double *)malloc(sizeof(double)*to_rbf->nrbf);
367        if ((src_rem == NULL) | (dst_rem == NULL)) {
368                fprintf(stderr, "%s: Out of memory in create_migration()\n",
369                                progname);
370                exit(1);
371        }
372                                                /* starting quantities */
373        memset(newmig->mtx, 0, sizeof(float)*from_rbf->nrbf*to_rbf->nrbf);
374        for (i = from_rbf->nrbf; i--; )
375                src_rem[i] = rbf_volume(&from_rbf->rbfa[i]) / from_rbf->vtotal;
376        for (j = to_rbf->nrbf; j--; )
377                dst_rem[j] = rbf_volume(&to_rbf->rbfa[j]) / to_rbf->vtotal;
345  
346 <        do {                                    /* move a bit at a time */
347 <                move_amt = migration_step(newmig, src_rem, dst_rem, &pmtx);
348 <                total_rem -= move_amt;
382 <        } while ((total_rem > end_thresh) & (move_amt > 0));
346 >                                                /* compute transport plan */
347 >        compute_nDSFs(from_rbf, to_rbf);
348 >        plan_transport(newmig);
349  
350          for (i = from_rbf->nrbf; i--; ) {       /* normalize final matrix */
351              double      nf = rbf_volume(&from_rbf->rbfa[i]);
# Line 389 | Line 355 | create_migration(RBFNODE *from_rbf, RBFNODE *to_rbf)
355                  mtx_coef(newmig,i,j) *= nf;     /* row now sums to 1.0 */
356          }
357          end_subprocess();                       /* exit here if subprocess */
392        free_routes(&pmtx);                     /* free working arrays */
393        free(src_rem);
394        free(dst_rem);
358          return(newmig);
359   }
360  
# Line 481 | Line 444 | mesh_from_edge(MIGRATION *edge)
444                                  ej1 = create_migration(tvert[0], edge->rbfv[1]);
445                          mesh_from_edge(ej0);
446                          mesh_from_edge(ej1);
447 +                        return;
448                  }
449 <        } else if (tvert[1] == NULL) {          /* grow mesh on left */
449 >        }
450 >        if (tvert[1] == NULL) {                 /* grow mesh on left */
451                  tvert[1] = find_chull_vert(edge->rbfv[1], edge->rbfv[0]);
452                  if (tvert[1] != NULL) {
453                          if (tvert[1]->ord > edge->rbfv[0]->ord)
# Line 503 | Line 468 | mesh_from_edge(MIGRATION *edge)
468   static void
469   check_normal_incidence(void)
470   {
471 <        static const FVECT      norm_vec = {.0, .0, 1.};
471 >        static FVECT            norm_vec = {.0, .0, 1.};
472          const int               saved_nprocs = nprocs;
473          RBFNODE                 *near_rbf, *mir_rbf, *rbf;
474          double                  bestd;
# Line 526 | Line 491 | check_normal_incidence(void)
491                  default:
492                          return;                 /* else we can interpolate */
493                  }
494 <                for (rbf = near_rbf->next; rbf != NULL; rbf = rbf->next) {
494 >                for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) {
495                          const double    d = input_orient*rbf->invec[2];
496                          if (d >= 1.-2.*FTINY)
497                                  return;         /* seems we have normal */
# Line 553 | Line 518 | check_normal_incidence(void)
518          memcpy(mir_rbf, near_rbf, n);
519          mir_rbf->ord = near_rbf->ord - 1;       /* not used, I think */
520          mir_rbf->next = NULL;
521 +        mir_rbf->ejl = NULL;
522          rev_rbf_symmetry(mir_rbf, MIRROR_X|MIRROR_Y);
523          nprocs = 1;                             /* compute migration matrix */
524 <        if (mig_list != create_migration(mir_rbf, near_rbf))
524 >        if (create_migration(mir_rbf, near_rbf) == NULL)
525                  exit(1);                        /* XXX should never happen! */
526 <                                                /* interpolate normal dist. */
527 <        rbf = e_advect_rbf(mig_list, norm_vec, 2*near_rbf->nrbf);
526 >        norm_vec[2] = input_orient;             /* interpolate normal dist. */
527 >        rbf = e_advect_rbf(mig_list, norm_vec, 0);
528          nprocs = saved_nprocs;                  /* final clean-up */
529          free(mir_rbf);
530          free(mig_list);
# Line 578 | Line 544 | build_mesh(void)
544          double          best2 = M_PI*M_PI;
545          RBFNODE         *shrt_edj[2];
546          RBFNODE         *rbf0, *rbf1;
547 +                                                /* average specular peak */
548 +        comp_bsdf_spec();
549                                                  /* add normal if needed */
550          check_normal_incidence();
551                                                  /* check if isotropic */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines