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

Comparing ray/src/gen/mkillum2.c (file contents):
Revision 2.37 by greg, Tue Aug 16 18:09:53 2011 UTC vs.
Revision 2.41 by greg, Thu Sep 15 22:34:41 2016 UTC

# Line 19 | Line 19 | static const char      RCSid[] = "$Id$";
19  
20   COLORV *        distarr = NULL;         /* distribution array */
21   int             distsiz = 0;
22 COLORV *        direct_discount = NULL; /* amount to take off direct */
22  
23  
24   void
# Line 46 | Line 45 | newdist(                       /* allocate & clear distribution array */
45   }
46  
47  
49 static void
50 new_discount()                  /* allocate space for direct contrib. record */
51 {
52        if (distsiz <= 0)
53                return;
54        direct_discount = (COLORV *)calloc(distsiz, sizeof(COLOR));
55        if (direct_discount == NULL)
56                error(SYSTEM, "out of memory in new_discount");
57 }
58
59
60 static void
61 done_discount()                 /* clear off direct contrib. record */
62 {
63        if (direct_discount == NULL)
64                return;
65        free(direct_discount);
66        direct_discount = NULL;
67 }
68
69
48   int
49   process_ray(                    /* process a ray result or report error */
50          RAY *r,
# Line 84 | Line 62 | process_ray(                   /* process a ray result or report error
62          multcolor(r->rcol, r->rcoef);   /* in case it's a source ray */
63          colp = &distarr[r->rno * 3];
64          addcolor(colp, r->rcol);
87        if (r->rsrc >= 0 &&             /* remember source contrib. */
88                        direct_discount != NULL) {
89                colp = &direct_discount[r->rno * 3];
90                addcolor(colp, r->rcol);
91        }
65          return(1);
66   }
67  
# Line 119 | Line 92 | void
92   srcsamps(                       /* sample sources from this surface position */
93          struct illum_args *il,
94          FVECT org,
95 <        FVECT nrm,
95 >        double eps,
96          MAT4 ixfm
97   )
98   {
# Line 130 | Line 103 | srcsamps(                      /* sample sources from this surface positi
103          double  d;
104          int  i, j;
105                                                  /* get sampling density */
106 <        if (il->sd == NULL && il->sampdens > 0) {
106 >        if (il->sampdens > 0) {
107                  i = PI * il->sampdens;
108                  nalt = sqrt(i/PI) + .5;
109                  nazi = PI*nalt + .5;
# Line 138 | Line 111 | srcsamps(                      /* sample sources from this surface positi
111          initsrcindex(&si);                      /* loop over (sub)sources */
112          for ( ; ; ) {
113                  VCOPY(sr.rorg, org);            /* pick side to shoot from */
141                if (il->sd != NULL) {
142                        int  sn = si.sn;
143                        if (si.sp+1 >= si.np) ++sn;
144                        if (sn >= nsources) break;
145                        if (source[sn].sflags & SDISTANT)
146                                d = DOT(source[sn].sloc, nrm);
147                        else {
148                                VSUB(v, source[sn].sloc, org);
149                                d = DOT(v, nrm);
150                        }
151                } else
152                        d = 1.0;                /* only transmission */
153                if (d < 0.0)
154                        d = -1.0001*il->thick - 5.*FTINY;
155                else
156                        d = 5.*FTINY;
157                VSUM(sr.rorg, sr.rorg, nrm, d);
114                  samplendx++;                    /* increment sample counter */
115                  if (!srcray(&sr, NULL, &si))
116                          break;                  /* end of sources */
# Line 163 | Line 119 | srcsamps(                      /* sample sources from this surface positi
119                          multv3(v, sr.rdir, ixfm);
120                  else
121                          VCOPY(v, sr.rdir);
122 <                if (il->sd != NULL) {
123 <                        i = getBSDF_incndx(il->sd, v);
124 <                        if (i < 0)
125 <                                continue;       /* must not be important */
126 <                        sr.rno = i;
171 <                        d = 1.0/getBSDF_incohm(il->sd, i);
172 <                } else {
173 <                        if (v[2] >= -FTINY)
174 <                                continue;       /* only sample transmission */
175 <                        v[0] = -v[0]; v[1] = -v[1]; v[2] = -v[2];
176 <                        sr.rno = flatindex(v, nalt, nazi);
177 <                        d = nalt*nazi*(1./PI) * v[2];
178 <                }
122 >                if (v[2] >= -FTINY)
123 >                        continue;               /* only sample transmission */
124 >                v[0] = -v[0]; v[1] = -v[1]; v[2] = -v[2];
125 >                sr.rno = flatindex(v, nalt, nazi);
126 >                d = nalt*nazi*(1./PI) * v[2];
127                  d *= si.dom;                    /* solid angle correction */
128                  scalecolor(sr.rcoef, d);
129 +                VSUM(sr.rorg, sr.rorg, sr.rdir, -eps);
130                  process_ray(&sr, ray_pqueue(&sr));
131          }
132   }
# Line 200 | Line 149 | mkaxes(                        /* compute u and v to go with n */
149          FVECT  n
150   )
151   {
152 <        register int  i;
204 <
205 <        v[0] = v[1] = v[2] = 0.0;
206 <        for (i = 0; i < 3; i++)
207 <                if (n[i] < 0.6 && n[i] > -0.6)
208 <                        break;
209 <        v[i] = 1.0;
210 <        fcross(u, v, n);
211 <        normalize(u);
152 >        getperpendicular(u, n, 1);
153          fcross(v, n, u);
154   }
155  
156  
157   static void
158   rounddir(               /* compute uniform spherical direction */
159 <        register FVECT  dv,
159 >        FVECT  dv,
160          double  alt,
161          double  azi
162   )
# Line 268 | Line 209 | flatindex(             /* compute index for hemispherical directi
209  
210  
211   int
271 printgeom(              /* print out detailed geometry for BSDF */
272        struct BSDF_data *sd,
273        char *xfrot,
274        FVECT ctr,
275        double s1,
276        double s2
277 )
278 {
279        static char     mgftemp[] = TEMPLATE;
280        char            cmdbuf[64];
281        FILE            *fp;
282        double          sca;
283
284        if (sd == NULL || sd->mgf == NULL)
285                return(0);
286        if (sd->dim[0] <= FTINY || sd->dim[1] <= FTINY)
287                return(0);
288        if ((s1 > s2) ^ (sd->dim[0] > sd->dim[1])) {
289                sca = s1; s1 = s2; s2 = sca;
290        }
291        s1 /= sd->dim[0];
292        s2 /= sd->dim[1];
293        sca = s1 > s2 ? s1 : s2;
294        strcpy(mgftemp, TEMPLATE);
295        if ((fp = fopen(mktemp(mgftemp), "w")) == NULL)
296                error(SYSTEM, "cannot create temporary file for MGF");
297                                        /* prepend our transform */
298        fprintf(fp, "xf%s -s %.5f -t %.5g %.5g %.5g\n",
299                        xfrot, sca, ctr[0], ctr[1], ctr[2]);
300                                        /* output given MGF description */
301        fputs(sd->mgf, fp);
302        fputs("\nxf\n", fp);
303        if (fclose(fp) == EOF)
304                error(SYSTEM, "error writing MGF temporary file");
305                                        /* execute mgf2rad to convert MGF */
306        strcpy(cmdbuf, "mgf2rad ");
307        strcpy(cmdbuf+8, mgftemp);
308        fflush(stdout);
309        system(cmdbuf);
310        unlink(mgftemp);                /* clean up */
311        return(1);
312 }
313
314
315 int
212   my_default(     /* default illum action */
213          OBJREC  *ob,
214          struct illum_args  *il,
# Line 341 | Line 237 | my_face(               /* make an illum face */
237          FVECT  dn, org, dir;
238          FVECT  u, v;
239          double  ur[2], vr[2];
240 +        double  epsilon;
241          MAT4  xfm;
242          char  xfrot[64];
243          int  nallow;
# Line 353 | Line 250 | my_face(               /* make an illum face */
250                  return(my_default(ob, il, nm));
251          }
252                                  /* set up sampling */
253 <        if (il->sd != NULL) {
254 <                if (!getBSDF_xfm(xfm, fa->norm, il->udir, xfrot)) {
358 <                        objerror(ob, WARNING, "illegal up direction");
359 <                        freeface(ob);
360 <                        return(my_default(ob, il, nm));
361 <                }
362 <                n = il->sd->ninc;
253 >        if (il->sampdens <= 0) {
254 >                nalt = nazi = 1;        /* diffuse assumption */
255          } else {
256 <                if (il->sampdens <= 0) {
257 <                        nalt = nazi = 1;        /* diffuse assumption */
258 <                } else {
367 <                        n = PI * il->sampdens;
368 <                        nalt = sqrt(n/PI) + .5;
369 <                        nazi = PI*nalt + .5;
370 <                }
371 <                n = nazi*nalt;
256 >                n = PI * il->sampdens;
257 >                nalt = sqrt(n/PI) + .5;
258 >                nazi = PI*nalt + .5;
259          }
260 +        n = nazi*nalt;
261          newdist(n);
262                                  /* take first edge >= sqrt(area) */
263          for (j = fa->nv-1, i = 0; i < fa->nv; j = i++) {
# Line 396 | Line 284 | my_face(               /* make an illum face */
284                  if (r2 < vr[0]) vr[0] = r2;
285                  if (r2 > vr[1]) vr[1] = r2;
286          }
399                                /* output detailed geometry? */
400        if (!(il->flags & IL_LIGHT) && il->sd != NULL && il->sd->mgf != NULL &&
401                        il->thick <= FTINY) {
402                for (j = 3; j--; )
403                        org[j] = .5*(ur[0]+ur[1])*u[j] +
404                                        .5*(vr[0]+vr[1])*v[j] +
405                                        fa->offset*fa->norm[j];
406                printgeom(il->sd, xfrot, org, ur[1]-ur[0], vr[1]-vr[0]);
407        }
287          dim[0] = random();
288                                  /* sample polygon */
289          nallow = 5*n*il->nsamps;
290 +        epsilon = .005*sqrt(fa->area);
291          for (dim[1] = 0; dim[1] < n; dim[1]++)
292                  for (i = 0; i < il->nsamps; i++) {
293                                          /* randomize direction */
294                      h = ilhash(dim, 2) + i;
295 <                    if (il->sd != NULL) {
296 <                        r_BSDF_incvec(dir, il->sd, dim[1], urand(h), xfm);
297 <                    } else {
298 <                        multisamp(sp, 2, urand(h));
299 <                        alti = dim[1]/nazi;
300 <                        r1 = (alti + sp[0])/nalt;
421 <                        r2 = (dim[1] - alti*nazi + sp[1] - .5)/nazi;
422 <                        flatdir(dn, r1, r2);
423 <                        for (j = 0; j < 3; j++)
295 >                    multisamp(sp, 2, urand(h));
296 >                    alti = dim[1]/nazi;
297 >                    r1 = (alti + sp[0])/nalt;
298 >                    r2 = (dim[1] - alti*nazi + sp[1] - .5)/nazi;
299 >                    flatdir(dn, r1, r2);
300 >                    for (j = 0; j < 3; j++)
301                              dir[j] = -dn[0]*u[j] - dn[1]*v[j] -
302                                                  dn[2]*fa->norm[j];
426                    }
303                                          /* randomize location */
304                      do {
305                          multisamp(sp, 2, urand(h+4862+nallow));
# Line 439 | Line 315 | my_face(               /* make an illum face */
315                          freeface(ob);
316                          return(my_default(ob, il, nm));
317                      }
318 <                    if (il->sd != NULL && DOT(dir, fa->norm) < -FTINY)
443 <                        r1 = -1.0001*il->thick - 5.*FTINY;
444 <                    else
445 <                        r1 = 5.*FTINY;
446 <                    for (j = 0; j < 3; j++)
447 <                        org[j] += r1*fa->norm[j];
318 >                    VSUM(org, org, dir, -epsilon);
319                                          /* send sample */
320                      raysamp(dim[1], org, dir);
321                  }
322                                  /* add in direct component? */
323 <        if (il->flags & IL_LIGHT || il->sd != NULL) {
323 >        if (il->flags & IL_LIGHT) {
324                  MAT4    ixfm;
325 <                if (il->sd == NULL) {
326 <                        for (i = 3; i--; ) {
327 <                                ixfm[i][0] = u[i];
328 <                                ixfm[i][1] = v[i];
329 <                                ixfm[i][2] = fa->norm[i];
459 <                                ixfm[i][3] = 0.;
460 <                        }
461 <                        ixfm[3][0] = ixfm[3][1] = ixfm[3][2] = 0.;
462 <                        ixfm[3][3] = 1.;
463 <                } else {
464 <                        if (!invmat4(ixfm, xfm))
465 <                                objerror(ob, INTERNAL,
466 <                                        "cannot invert BSDF transform");
467 <                        if (!(il->flags & IL_LIGHT))
468 <                                new_discount();
325 >                for (i = 3; i--; ) {
326 >                        ixfm[i][0] = u[i];
327 >                        ixfm[i][1] = v[i];
328 >                        ixfm[i][2] = fa->norm[i];
329 >                        ixfm[i][3] = 0.;
330                  }
331 +                ixfm[3][0] = ixfm[3][1] = ixfm[3][2] = 0.;
332 +                ixfm[3][3] = 1.;
333                  dim[0] = random();
334                  nallow = 10*il->nsamps;
335                  for (i = 0; i < il->nsamps; i++) {
# Line 487 | Line 350 | my_face(               /* make an illum face */
350                          return(my_default(ob, il, nm));
351                      }
352                                          /* sample source rays */
353 <                    srcsamps(il, org, fa->norm, ixfm);
353 >                    srcsamps(il, org, epsilon, ixfm);
354                  }
355          }
356                                  /* wait for all rays to finish */
357          rayclean();
495        if (il->sd != NULL) {   /* run distribution through BSDF */
496                nalt = sqrt(il->sd->nout/PI) + .5;
497                nazi = PI*nalt + .5;
498                redistribute(il->sd, nalt, nazi, u, v, fa->norm, xfm);
499                done_discount();
500                if (!il->sampdens)
501                        il->sampdens = nalt*nazi/PI + .999;
502        }
358                                  /* write out the face and its distribution */
359          if (average(il, distarr, n)) {
360                  if (il->sampdens > 0)
# Line 515 | Line 370 | my_face(               /* make an illum face */
370  
371   int
372   my_sphere(      /* make an illum sphere */
373 <        register OBJREC  *ob,
373 >        OBJREC  *ob,
374          struct illum_args  *il,
375          char  *nm
376   )
# Line 525 | Line 380 | my_sphere(     /* make an illum sphere */
380          double  sp[4], r1, r2, r3;
381          FVECT  org, dir;
382          FVECT  u, v;
383 <        register int  i, j;
383 >        int  i, j;
384                                  /* check arguments */
385          if (ob->oargs.nfargs != 4)
386                  objerror(ob, USER, "bad # of arguments");
# Line 537 | Line 392 | my_sphere(     /* make an illum sphere */
392                  nalt = sqrt(2./PI*n) + .5;
393                  nazi = PI/2.*nalt + .5;
394          }
540        if (il->sd != NULL)
541                objerror(ob, WARNING, "BSDF ignored");
395          n = nalt*nazi;
396          newdist(n);
397          dim[0] = random();
# Line 602 | Line 455 | my_ring(               /* make an illum ring */
455                                  /* get/check arguments */
456          co = getcone(ob, 0);
457                                  /* set up sampling */
458 <        if (il->sd != NULL) {
459 <                if (!getBSDF_xfm(xfm, co->ad, il->udir, NULL)) {
607 <                        objerror(ob, WARNING, "illegal up direction");
608 <                        freecone(ob);
609 <                        return(my_default(ob, il, nm));
610 <                }
611 <                n = il->sd->ninc;
458 >        if (il->sampdens <= 0) {
459 >                nalt = nazi = 1;        /* diffuse assumption */
460          } else {
461 <                if (il->sampdens <= 0) {
462 <                        nalt = nazi = 1;        /* diffuse assumption */
463 <                } else {
616 <                        n = PI * il->sampdens;
617 <                        nalt = sqrt(n/PI) + .5;
618 <                        nazi = PI*nalt + .5;
619 <                }
620 <                n = nazi*nalt;
461 >                n = PI * il->sampdens;
462 >                nalt = sqrt(n/PI) + .5;
463 >                nazi = PI*nalt + .5;
464          }
465 +        n = nazi*nalt;
466          newdist(n);
467          mkaxes(u, v, co->ad);
468          dim[0] = random();
# Line 628 | Line 472 | my_ring(               /* make an illum ring */
472                                          /* next sample point */
473                      h = ilhash(dim,2) + i;
474                                          /* randomize direction */
475 <                    if (il->sd != NULL) {
476 <                        r_BSDF_incvec(dir, il->sd, dim[1], urand(h), xfm);
477 <                    } else {
478 <                        multisamp(sp, 2, urand(h));
479 <                        alti = dim[1]/nazi;
480 <                        r1 = (alti + sp[0])/nalt;
481 <                        r2 = (dim[1] - alti*nazi + sp[1] - .5)/nazi;
638 <                        flatdir(dn, r1, r2);
639 <                        for (j = 0; j < 3; j++)
640 <                                dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*co->ad[j];
641 <                    }
475 >                    multisamp(sp, 2, urand(h));
476 >                    alti = dim[1]/nazi;
477 >                    r1 = (alti + sp[0])/nalt;
478 >                    r2 = (dim[1] - alti*nazi + sp[1] - .5)/nazi;
479 >                    flatdir(dn, r1, r2);
480 >                    for (j = 0; j < 3; j++)
481 >                        dir[j] = -dn[0]*u[j] - dn[1]*v[j] - dn[2]*co->ad[j];
482                                          /* randomize location */
483                      multisamp(sp, 2, urand(h+8371));
484                      r3 = sqrt(CO_R0(co)*CO_R0(co) +
# Line 646 | Line 486 | my_ring(               /* make an illum ring */
486                      r2 = 2.*PI*sp[1];
487                      r1 = r3*cos(r2);
488                      r2 = r3*sin(r2);
489 <                    if (il->sd != NULL && DOT(dir, co->ad) < -FTINY)
650 <                        r3 = -1.0001*il->thick - 5.*FTINY;
651 <                    else
652 <                        r3 = 5.*FTINY;
489 >                    r3 = 5.*FTINY;
490                      for (j = 0; j < 3; j++)
491                          org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j] +
492                                                  r3*co->ad[j];
# Line 657 | Line 494 | my_ring(               /* make an illum ring */
494                      raysamp(dim[1], org, dir);
495                  }
496                                  /* add in direct component? */
497 <        if (il->flags & IL_LIGHT || il->sd != NULL) {
497 >        if (il->flags & IL_LIGHT) {
498                  MAT4    ixfm;
499 <                if (il->sd == NULL) {
500 <                        for (i = 3; i--; ) {
501 <                                ixfm[i][0] = u[i];
502 <                                ixfm[i][1] = v[i];
503 <                                ixfm[i][2] = co->ad[i];
667 <                                ixfm[i][3] = 0.;
668 <                        }
669 <                        ixfm[3][0] = ixfm[3][1] = ixfm[3][2] = 0.;
670 <                        ixfm[3][3] = 1.;
671 <                } else {
672 <                        if (!invmat4(ixfm, xfm))
673 <                                objerror(ob, INTERNAL,
674 <                                        "cannot invert BSDF transform");
675 <                        if (!(il->flags & IL_LIGHT))
676 <                                new_discount();
499 >                for (i = 3; i--; ) {
500 >                        ixfm[i][0] = u[i];
501 >                        ixfm[i][1] = v[i];
502 >                        ixfm[i][2] = co->ad[i];
503 >                        ixfm[i][3] = 0.;
504                  }
505 +                ixfm[3][0] = ixfm[3][1] = ixfm[3][2] = 0.;
506 +                ixfm[3][3] = 1.;
507                  dim[0] = random();
508                  for (i = 0; i < il->nsamps; i++) {
509                                          /* randomize location */
# Line 688 | Line 517 | my_ring(               /* make an illum ring */
517                      for (j = 0; j < 3; j++)
518                          org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j];
519                                          /* sample source rays */
520 <                    srcsamps(il, org, co->ad, ixfm);
520 >                    srcsamps(il, org, 5.*FTINY, ixfm);
521                  }
522          }
523                                  /* wait for all rays to finish */
524          rayclean();
696        if (il->sd != NULL) {   /* run distribution through BSDF */
697                nalt = sqrt(il->sd->nout/PI) + .5;
698                nazi = PI*nalt + .5;
699                redistribute(il->sd, nalt, nazi, u, v, co->ad, xfm);
700                done_discount();
701                if (!il->sampdens)
702                        il->sampdens = nalt*nazi/PI + .999;
703        }
525                                  /* write out the ring and its distribution */
526          if (average(il, distarr, n)) {
527                  if (il->sampdens > 0)
# Line 711 | Line 532 | my_ring(               /* make an illum ring */
532                                  /* clean up */
533          freecone(ob);
534          return(1);
714 }
715
716
717 void
718 redistribute(           /* pass distarr ray sums through BSDF */
719        struct BSDF_data *b,
720        int nalt,
721        int nazi,
722        FVECT u,
723        FVECT v,
724        FVECT w,
725        MAT4 xm
726 )
727 {
728        int     nout = 0;
729        MAT4    mymat, inmat;
730        COLORV  *idist;
731        COLORV  *cp;
732        FVECT   dv;
733        double  wt;
734        int     i, j, k, c, o;
735        COLOR   col, cinc;
736                                        /* copy incoming distribution */
737        if (b->ninc > distsiz)
738                error(INTERNAL, "error 1 in redistribute");
739        idist = (COLORV *)malloc(sizeof(COLOR)*b->ninc);
740        if (idist == NULL)
741                error(SYSTEM, "out of memory in redistribute");
742        memcpy(idist, distarr, sizeof(COLOR)*b->ninc);
743                                        /* compose direction transform */
744        for (i = 3; i--; ) {
745                mymat[i][0] = u[i];
746                mymat[i][1] = v[i];
747                mymat[i][2] = w[i];
748                mymat[i][3] = 0.;
749        }
750        mymat[3][0] = mymat[3][1] = mymat[3][2] = 0.;
751        mymat[3][3] = 1.;
752        if (xm != NULL)
753                multmat4(mymat, xm, mymat);
754        for (i = 3; i--; ) {            /* make sure it's normalized */
755                wt = 1./sqrt(   mymat[0][i]*mymat[0][i] +
756                                mymat[1][i]*mymat[1][i] +
757                                mymat[2][i]*mymat[2][i] );
758                for (j = 3; j--; )
759                        mymat[j][i] *= wt;
760        }
761        if (!invmat4(inmat, mymat))     /* need inverse as well */
762                error(INTERNAL, "cannot invert BSDF transform");
763        newdist(nalt*nazi);             /* resample distribution */
764        for (i = b->ninc; i--; ) {
765                int     direct_out = -1;
766                COLOR   cdir;
767                getBSDF_incvec(dv, b, i);       /* compute incident irrad. */
768                multv3(dv, dv, mymat);
769                if (dv[2] < 0.0) {
770                        dv[0] = -dv[0]; dv[1] = -dv[1]; dv[2] = -dv[2];
771                        direct_out += (direct_discount != NULL);
772                }
773                wt = getBSDF_incohm(b, i);
774                wt *= dv[2];                    /* solid_angle*cosine(theta) */
775                cp = &idist[3*i];
776                copycolor(cinc, cp);
777                scalecolor(cinc, wt);
778                if (!direct_out) {              /* discount direct contr. */
779                        cp = &direct_discount[3*i];
780                        copycolor(cdir, cp);
781                        scalecolor(cdir, -wt);
782                        if (b->nout != b->ninc)
783                                direct_out = flatindex(dv, nalt, nazi);
784                        else
785                                direct_out = i; /* assumes dist. mirroring */
786                }
787                for (k = nalt; k--; )           /* loop over distribution */
788                  for (j = nazi; j--; ) {
789                    int rstart = random();
790                    for (c = NBSDFSAMPS; c--; ) {
791                        double  sp[2];
792                        multisamp(sp, 2, urand(rstart+c));
793                        flatdir(dv, (k + sp[0])/nalt,
794                                        (j + .5 - sp[1])/nazi);
795                        multv3(dv, dv, inmat);
796                                                /* evaluate BSDF @ outgoing */
797                        o = getBSDF_outndx(b, dv);
798                        if (o < 0) {
799                                nout++;
800                                continue;
801                        }
802                        wt = BSDF_value(b, i, o) * (1./NBSDFSAMPS);
803                        copycolor(col, cinc);
804                        if (b->nout != b->ninc)
805                                o = k*nazi + j;
806                        if (o == direct_out)
807                                addcolor(col, cdir);    /* minus direct */
808                        scalecolor(col, wt);
809                        cp = &distarr[3*(k*nazi + j)];
810                        addcolor(cp, col);      /* sum into distribution */
811                    }
812                  }
813        }
814        free(idist);                    /* free temp space */
815        if (nout) {
816                sprintf(errmsg, "missing %.1f%% of BSDF directions",
817                                100.*nout/(b->ninc*nalt*nazi*NBSDFSAMPS));
818                error(WARNING, errmsg);
819        }
535   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines