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.39 by greg, Thu Dec 4 05:26:28 2014 UTC vs.
Revision 2.43 by greg, Fri Nov 17 20:02:07 2023 UTC

# Line 13 | Line 13 | static const char      RCSid[] = "$Id$";
13   #include  "source.h"
14   #include  "paths.h"
15  
16 < #ifndef NBSDFSAMPS
17 < #define NBSDFSAMPS      256             /* BSDF resampling count */
16 > #ifndef R_EPS
17 > #define R_EPS           0.005           /* relative epsilon for ray origin */
18   #endif
19  
20   COLORV *        distarr = NULL;         /* distribution array */
# Line 59 | Line 59 | process_ray(                   /* process a ray result or report error
59                  error(USER, "ray tracing process died");
60          if (r->rno >= distsiz)
61                  error(INTERNAL, "bad returned index in process_ray");
62 <        multcolor(r->rcol, r->rcoef);   /* in case it's a source ray */
62 >        smultscolor(r->rcol, r->rcoef); /* in case it's a source ray */
63          colp = &distarr[r->rno * 3];
64 <        addcolor(colp, r->rcol);
64 >        addscolor(colp, r->rcol);
65          return(1);
66   }
67  
# Line 92 | 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 111 | 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 */
114                d = 5.*FTINY;
115                VSUM(sr.rorg, sr.rorg, nrm, d);
114                  samplendx++;                    /* increment sample counter */
115                  if (!srcray(&sr, NULL, &si))
116                          break;                  /* end of sources */
# Line 122 | Line 120 | srcsamps(                      /* sample sources from this surface positi
120                  else
121                          VCOPY(v, sr.rdir);
122                  if (v[2] >= -FTINY)
123 <                        continue;       /* only sample transmission */
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);
128 >                scalescolor(sr.rcoef, d);
129 >                VSUM(sr.rorg, sr.rorg, sr.rdir, -eps);
130                  process_ray(&sr, ray_pqueue(&sr));
131          }
132   }
# Line 150 | Line 149 | mkaxes(                        /* compute u and v to go with n */
149          FVECT  n
150   )
151   {
152 <        getperpendicular(u, n);
152 >        getperpendicular(u, n, 1);
153          fcross(v, n, u);
154   }
155  
# Line 238 | 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 287 | Line 287 | my_face(               /* make an illum face */
287          dim[0] = random();
288                                  /* sample polygon */
289          nallow = 5*n*il->nsamps;
290 +        epsilon = R_EPS*sqrt(fa->area);
291          for (dim[1] = 0; dim[1] < n; dim[1]++)
292                  for (i = 0; i < il->nsamps; i++) {
293                                          /* randomize direction */
# Line 314 | Line 315 | my_face(               /* make an illum face */
315                          freeface(ob);
316                          return(my_default(ob, il, nm));
317                      }
318 <                    r1 = 5.*FTINY;
318 <                    for (j = 0; j < 3; j++)
319 <                        org[j] += r1*fa->norm[j];
318 >                    VSUM(org, org, dir, -epsilon);
319                                          /* send sample */
320                      raysamp(dim[1], org, dir);
321                  }
# Line 351 | 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 */
# Line 447 | Line 446 | my_ring(               /* make an illum ring */
446          int  dim[2];
447          int  n, nalt, nazi, alti;
448          double  sp[2], r1, r2, r3;
449 +        double  epsilon;
450          int  h;
451          FVECT  dn, org, dir;
452          FVECT  u, v;
453          MAT4  xfm;
454          CONE  *co;
455          int  i, j;
456 <                                /* get/check arguments */
456 >                                        /* get/check arguments */
457          co = getcone(ob, 0);
458 <                                /* set up sampling */
458 >        if (co == NULL)
459 >                objerror(ob, USER, "cannot create illum");
460 >                                        /* set up sampling */
461          if (il->sampdens <= 0) {
462                  nalt = nazi = 1;        /* diffuse assumption */
463          } else {
# Line 463 | Line 465 | my_ring(               /* make an illum ring */
465                  nalt = sqrt(n/PI) + .5;
466                  nazi = PI*nalt + .5;
467          }
468 +        epsilon = R_EPS*CO_R1(co);
469          n = nazi*nalt;
470          newdist(n);
471          mkaxes(u, v, co->ad);
# Line 487 | Line 490 | my_ring(               /* make an illum ring */
490                      r2 = 2.*PI*sp[1];
491                      r1 = r3*cos(r2);
492                      r2 = r3*sin(r2);
490                    r3 = 5.*FTINY;
493                      for (j = 0; j < 3; j++)
494                          org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j] +
495 <                                                r3*co->ad[j];
495 >                                                epsilon*co->ad[j];
496                                          /* send sample */
497                      raysamp(dim[1], org, dir);
498                  }
# Line 518 | Line 520 | my_ring(               /* make an illum ring */
520                      for (j = 0; j < 3; j++)
521                          org[j] = CO_P0(co)[j] + r1*u[j] + r2*v[j];
522                                          /* sample source rays */
523 <                    srcsamps(il, org, co->ad, ixfm);
523 >                    srcsamps(il, org, epsilon, ixfm);
524                  }
525          }
526                                  /* wait for all rays to finish */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines