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.44 by greg, Thu May 1 16:06:11 2014 UTC vs.
Revision 2.45 by greg, Thu May 1 22:34:25 2014 UTC

# Line 161 | Line 161 | badsample:
161   static float *
162   getambdiffs(AMBHEMI *hp)
163   {
164 <        float   *earr = calloc(hp->ns*hp->ns, sizeof(float));
164 >        float   *earr = (float *)calloc(hp->ns*hp->ns, sizeof(float));
165          float   *ep;
166          AMBSAMP *ap;
167          double  b, d2;
# Line 606 | Line 606 | doambient(                             /* compute ambient component */
606   )
607   {
608          AMBHEMI *hp = inithemi(rcol, r, wt);
609 <        int     cnt = 0;
609 >        int     cnt;
610          FVECT   my_uv[2];
611          double  d, K, acol[3];
612          AMBSAMP *ap;
# Line 624 | Line 624 | doambient(                             /* compute ambient component */
624                  dg[0] = dg[1] = 0.0;
625                                          /* sample the hemisphere */
626          acol[0] = acol[1] = acol[2] = 0.0;
627 +        cnt = 0;
628          for (i = hp->ns; i--; )
629                  for (j = hp->ns; j--; )
630                          if ((ap = ambsample(hp, i, j)) != NULL) {
# Line 648 | Line 649 | doambient(                             /* compute ambient component */
649                  free(hp);
650                  return(-1);             /* no radius or gradient calc. */
651          }
652 <        if (bright(acol) > FTINY) {     /* normalize Y values */
653 <                d = 0.99*cnt/bright(acol);
652 >        if ((d = bright(acol)) > FTINY) {       /* normalize Y values */
653 >                d = 0.99*(hp->ns*hp->ns)/d;
654                  K = 0.01;
655 <        } else {                        /* geometric Hessian fall-back */
655 <                d = 0.0;
655 >        } else {                        /* or fall back on geometric Hessian */
656                  K = 1.0;
657                  pg = NULL;
658                  dg = NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines