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.57 by greg, Fri May 9 22:53:11 2014 UTC vs.
Revision 2.59 by greg, Fri May 16 23:39:24 2014 UTC

# Line 600 | Line 600 | ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, c
600          const double    ang_step = ang_res/((int)(16/PI*ang_res) + (1+FTINY));
601          double          avg_d = 0;
602          uint32          flgs = 0;
603 +        FVECT           vec;
604 +        double          u, v;
605 +        double          ang, a1;
606          int             i, j;
607                                          /* don't bother for a few samples */
608          if (hp->ns < 12)
# Line 617 | Line 620 | ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, c
620          for (i = 0; i < hp->ns; i++)
621              for (j = 0; j < hp->ns; j += !i|(i==hp->ns-1) ? 1 : hp->ns-1) {
622                  AMBSAMP *ap = &ambsam(hp,i,j);
620                FVECT   vec;
621                double  u, v;
622                double  ang, a1;
623                int     abp;
623                  if ((ap->d <= FTINY) | (ap->d >= max_d))
624                          continue;       /* too far or too near */
625                  VSUB(vec, ap->p, hp->rp->rop);
# Line 632 | Line 631 | ambcorral(AMBHEMI *hp, FVECT uv[2], const double r0, c
631                  for (a1 = ang-.5*ang_res; a1 <= ang+.5*ang_res; a1 += ang_step)
632                          flgs |= 1L<<(int)(16/PI*(a1 + 2.*PI*(a1 < 0)));
633              }
634 +                                        /* add low-angle incident (< 20deg) */
635 +        if (fabs(hp->rp->rod) <= 0.342) {
636 +                u = -DOT(hp->rp->rdir, uv[0]);
637 +                v = -DOT(hp->rp->rdir, uv[1]);
638 +                if ((r0*r0*u*u + r1*r1*v*v) > hp->rp->rot*hp->rp->rot) {
639 +                        ang = atan2a(v, u);
640 +                        ang += 2.*PI*(ang < 0);
641 +                        ang *= 16/PI;
642 +                        if ((ang < .5) | (ang >= 31.5))
643 +                                flgs |= 0x80000001;
644 +                        else
645 +                                flgs |= 3L<<(int)(ang-.5);
646 +                }
647 +        }
648          return(flgs);
649   }
650  
# Line 676 | Line 689 | doambient(                             /* compute ambient component */
689                                  addcolor(acol, ap->v);
690                                  ++cnt;
691                          }
692 <        if (!cnt) {
693 <                setcolor(rcol, 0.0, 0.0, 0.0);
681 <                free(hp);
682 <                return(0);              /* no valid samples */
683 <        }
684 <        if (cnt < hp->ns*hp->ns) {      /* incomplete sampling? */
692 >        if ((hp->ns < 4) | (cnt < hp->ns*hp->ns)) {
693 >                free(hp);               /* inadequate sampling */
694                  copycolor(rcol, acol);
695 <                free(hp);
687 <                return(-1);             /* return value w/o Hessian */
695 >                return(-cnt);           /* value-only result */
696          }
697          cnt = ambssamp*wt + 0.5;        /* perform super-sampling? */
698          if (cnt > 8)
# Line 692 | Line 700 | doambient(                             /* compute ambient component */
700          copycolor(rcol, acol);          /* final indirect irradiance/PI */
701          if ((ra == NULL) & (pg == NULL) & (dg == NULL)) {
702                  free(hp);
703 <                return(-1);             /* no radius or gradient calc. */
703 >                return(-1);             /* no Hessian or gradients requested */
704          }
705          if ((d = bright(acol)) > FTINY) {       /* normalize Y values */
706                  d = 0.99*(hp->ns*hp->ns)/d;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines