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

Comparing ray/src/rt/ambcomp.c (file contents):
Revision 2.37 by greg, Sat Apr 26 05:09:54 2014 UTC vs.
Revision 2.38 by greg, Sat Apr 26 15:54:17 2014 UTC

# Line 70 | Line 70 | inithemi(                      /* initialize sampling hemisphere */
70          d = 1.0/(n*n);
71          scalecolor(hp->acoef, d);
72                                          /* make tangent plane axes */
73 <        hp->uy[0] = hp->uy[1] = hp->uy[2] = 0.0;
73 >        hp->uy[0] = 0.5 - frandom();
74 >        hp->uy[1] = 0.5 - frandom();
75 >        hp->uy[2] = 0.5 - frandom();
76          for (i = 3; i--; )
77                  if ((-0.6 < r->ron[i]) & (r->ron[i] < 0.6))
78                          break;
# Line 317 | Line 319 | eigenvectors(FVECT uv[2], float ra[2], FVECT hessian[3
319          hess2[0][1] = DOT(uv[0], b);
320          hess2[1][0] = DOT(uv[1], a);
321          hess2[1][1] = DOT(uv[1], b);
322 <                                        /* compute eigenvalues */
323 <        if ( quadratic(evalue, 1.0, -hess2[0][0]-hess2[1][1],
324 <                        hess2[0][0]*hess2[1][1]-hess2[0][1]*hess2[1][0]) != 2 ||
325 <                        ((evalue[0] = fabs(evalue[0])) <= FTINY*FTINY) |
322 >                                        /* compute eigenvalue(s) */
323 >        i = quadratic(evalue, 1.0, -hess2[0][0]-hess2[1][1],
324 >                        hess2[0][0]*hess2[1][1]-hess2[0][1]*hess2[1][0]);
325 >        if (i == 1)                     /* double-root (circle) */
326 >                evalue[1] = evalue[0];
327 >        if (!i || ((evalue[0] = fabs(evalue[0])) <= FTINY*FTINY) |
328                          ((evalue[1] = fabs(evalue[1])) <= FTINY*FTINY) )
329                  error(INTERNAL, "bad eigenvalue calculation");
330  
# Line 497 | Line 501 | doambient(                             /* compute ambient component */
501          AMBHEMI                 *hp = inithemi(rcol, r, wt);
502          int                     cnt = 0;
503          FVECT                   my_uv[2];
504 <        double                  d, acol[3];
504 >        double                  d, K, acol[3];
505          struct s_ambsamp        *ap;
506          int                     i, j;
507                                          /* check/initialize */
# Line 530 | Line 534 | doambient(                             /* compute ambient component */
534                  free(hp);
535                  return(-1);             /* no radius or gradient calc. */
536          }
537 <        if (bright(acol) > FTINY)       /* normalize Y values */
538 <                d = cnt/bright(acol);
539 <        else
537 >        if (bright(acol) > FTINY) {     /* normalize Y values */
538 >                d = 0.99*cnt/bright(acol);
539 >                K = 0.01;
540 >        } else {                        /* geometric Hessian fall-back */
541                  d = 0.0;
542 +                K = 1.0;
543 +                pg = NULL;
544 +                dg = NULL;
545 +        }
546          ap = hp->sa;                    /* relative Y channel from here on... */
547          for (i = hp->ns*hp->ns; i--; ap++)
548 <                colval(ap->v,CIEY) = bright(ap->v)*d + 0.01;
548 >                colval(ap->v,CIEY) = bright(ap->v)*d + K;
549  
550          if (uv == NULL)                 /* make sure we have axis pointers */
551                  uv = my_uv;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines