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

Comparing ray/src/rt/ambient.c (file contents):
Revision 1.9 by greg, Fri Jan 19 00:00:05 1990 UTC vs.
Revision 1.12 by greg, Wed May 22 12:44:39 1991 UTC

# Line 34 | Line 34 | extern int  ambounce;          /* number of ambient bounces */
34   extern char  *amblist[];        /* ambient include/exclude list */
35   extern int  ambincl;            /* include == 1, exclude == 0 */
36  
37 < OBJECT  ambset[256]={0};        /* ambient include/exclude set */
37 > #define  MAXASET        511     /* maximum number of elements in ambient set */
38 > OBJECT  ambset[MAXASET+1]={0};  /* ambient include/exclude set */
39  
40   double  maxarad;                /* maximum ambient radius */
41   double  minarad;                /* minimum ambient radius */
# Line 76 | Line 77 | setambient(afile)                      /* initialize calculation */
77   char  *afile;
78   {
79          long  ftell();
79        OBJECT  obj;
80          AMBVAL  amb;
81  
82          maxarad = thescene.cusize / 2.0;                /* maximum radius */
# Line 102 | Line 102 | char  *afile;
102   ambnotify(obj)                  /* record new modifier */
103   OBJECT  obj;
104   {
105 +        static int  hitlimit = 0;
106          register OBJREC  *o = objptr(obj);
107          register char  **amblp;
108  
109 <        if (!ismodifier(o->otype))
109 >        if (hitlimit || !ismodifier(o->otype))
110                  return;
111          for (amblp = amblist; *amblp != NULL; amblp++)
112                  if (!strcmp(o->oname, *amblp)) {
113 +                        if (ambset[0] >= MAXASET) {
114 +                                error(WARNING, "too many modifiers in ambient list");
115 +                                hitlimit++;
116 +                                return;         /* should this be fatal? */
117 +                        }
118                          insertelem(ambset, obj);
119                          return;
120                  }
# Line 272 | Line 278 | register RAY  *r;
278   {
279          extern int  ambcmp();
280          extern double  sin(), cos(), sqrt();
281 +        int  hlist[4];
282          double  phi, xd, yd, zd;
283          double  b, b2;
284          register AMBSAMP  *div;
# Line 306 | Line 313 | register RAY  *r;
313          fcross(ux, r->ron, uy);
314          normalize(ux);
315          fcross(uy, ux, r->ron);
316 +                                        /* set up urand */
317 +        hlist[0] = r->rno;
318                                                  /* sample divisions */
319          arad = 0.0;
320          ne = 0;
321 <        for (i = 0; i < nt; i++)
321 >        for (i = 0; i < nt; i++) {
322 >                hlist[1] = i;
323                  for (j = 0; j < np; j++) {
324                          rayorigin(&ar, r, AMBIENT, 0.5);        /* pretested */
325 <                        zd = sqrt((i+frandom())/nt);
326 <                        phi = 2.0*PI * (j+frandom())/np;
325 >                        hlist[2] = j;
326 >                        hlist[3] = 0;
327 >                        zd = sqrt((i+urand(ilhash(hlist,4)))/nt);
328 >                        hlist[3] = 1;
329 >                        phi = 2.0*PI * (j+urand(ilhash(hlist,4)))/np;
330                          xd = cos(phi) * zd;
331                          yd = sin(phi) * zd;
332                          zd = sqrt(1.0 - zd*zd);
333                          for (k = 0; k < 3; k++)
334                                  ar.rdir[k] = xd*ux[k]+yd*uy[k]+zd*r->ron[k];
335 +                        dimlist[ndims++] = i*np + j + 38813;
336                          rayvalue(&ar);
337 +                        ndims--;
338                          if (ar.rot < FHUGE)
339                                  arad += 1.0 / ar.rot;
340                          if (ns > 0) {                   /* save division */
# Line 357 | Line 372 | register RAY  *r;
372                          } else
373                                  addcolor(acol, ar.rcol);
374                  }
375 +        }
376          for (k = 0; k < ne; k++) {              /* compute errors */
377                  if (div[k].n > 1)
378                          div[k].k /= div[k].n;
# Line 372 | Line 388 | register RAY  *r;
388                                                  /* super-sample */
389          for (i = ns; i > 0; i--) {
390                  rayorigin(&ar, r, AMBIENT, 0.5);        /* pretested */
391 <                zd = sqrt((div[0].t+frandom())/nt);
392 <                phi = 2.0*PI * (div[0].p+frandom())/np;
391 >                hlist[1] = div[0].t;
392 >                hlist[2] = div[0].p;
393 >                hlist[3] = 0;
394 >                zd = sqrt((div[0].t+urand(ilhash(hlist,4)+div[0].n))/nt);
395 >                hlist[3] = 1;
396 >                phi = 2.0*PI * (div[0].p+urand(ilhash(hlist,4)+div[0].n))/np;
397                  xd = cos(phi) * zd;
398                  yd = sin(phi) * zd;
399                  zd = sqrt(1.0 - zd*zd);
400                  for (k = 0; k < 3; k++)
401                          ar.rdir[k] = xd*ux[k]+yd*uy[k]+zd*r->ron[k];
402 +                dimlist[ndims++] = div[0].t*np + div[0].p + 38813;
403 +                rayvalue(&ar);
404 +                ndims--;
405                  rayvalue(&ar);
406                  if (ar.rot < FHUGE)
407                          arad += 1.0 / ar.rot;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines