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

Comparing ray/src/rt/source.c (file contents):
Revision 2.24 by greg, Wed Apr 17 14:02:18 1996 UTC vs.
Revision 2.25 by greg, Tue May 28 13:41:41 1996 UTC

# Line 381 | Line 381 | register RAY  *r;
381          int  nsamps;
382          RAY  sr;
383          SRCINDEX  si;
384 <        double  t, lastt, d;
385 <        COLOR  cumval, ctmp;
384 >        double  t, d;
385 >        double  re, ge, be;
386 >        COLOR  cvext;
387          int  i, j;
388  
389          if (r->slights == NULL || r->slights[0] == 0
# Line 397 | Line 398 | register RAY  *r;
398          oldsampndx = samplendx;
399          samplendx = random()&0x7fff;            /* randomize */
400          for (i = r->slights[0]; i > 0; i--) {   /* for each source */
401 <                setcolor(cumval, 0., 0., 0.);
401 <                lastt = r->rot;
402 <                for (j = nsamps; j-- > 0; ) {   /* for each sample position */
401 >                for (j = 0; j < nsamps; j++) {  /* for each sample position */
402                          samplendx++;
403                          t = r->rot * (j+frandom())/nsamps;
404 +                                                        /* extinction */
405 +                        re = t*colval(r->cext,RED);
406 +                        ge = t*colval(r->cext,GRN);
407 +                        be = t*colval(r->cext,BLU);
408 +                        setcolor(cvext, re > 92. ? 0. : exp(-re),
409 +                                        ge > 92. ? 0. : exp(-ge),
410 +                                        be > 92. ? 0. : exp(-be));
411 +                        if (intens(cvext) <= FTINY)
412 +                                break;                  /* too far away */
413                          sr.rorg[0] = r->rorg[0] + r->rdir[0]*t;
414                          sr.rorg[1] = r->rorg[1] + r->rdir[1]*t;
415                          sr.rorg[2] = r->rorg[2] + r->rdir[2]*t;
# Line 418 | Line 426 | register RAY  *r;
426                          rayvalue(&sr);                  /* eval. source ray */
427                          if (bright(sr.rcol) <= FTINY)
428                                  continue;
421                                                        /* compute fall-off */
422                        d = lastt - t;
423                        setcolor(ctmp,  1.-d*colval(r->cext,RED),
424                                        1.-d*colval(r->cext,GRN),
425                                        1.-d*colval(r->cext,BLU));
426                        multcolor(cumval, ctmp);
427                        lastt = t;
429                          if (r->gecc <= FTINY)           /* compute P(theta) */
430                                  d = 1.;
431                          else {
432                                  d = DOT(r->rdir, sr.rdir);
433 <                                d = sqrt(1. + r->gecc*r->gecc - 2.*r->gecc*d);
434 <                                d = (1. - r->gecc*r->gecc) / (d*d*d);
433 >                                d = 1. + r->gecc*r->gecc - 2.*r->gecc*d;
434 >                                d = (1. - r->gecc*r->gecc) / (d*sqrt(d));
435                          }
436                                                          /* other factors */
437                          d *= si.dom * r->rot / (4.*PI*nsamps);
438                          multcolor(sr.rcol, r->cext);
439                          multcolor(sr.rcol, r->albedo);
440                          scalecolor(sr.rcol, d);
441 <                        addcolor(cumval, sr.rcol);
441 >                        multcolor(sr.rcol, cvext);
442 >                        addcolor(r->rcol, sr.rcol);     /* add it in */
443                  }
442                                                /* final fall-off */
443                setcolor(ctmp,  1.-lastt*colval(r->cext,RED),
444                                1.-lastt*colval(r->cext,GRN),
445                                1.-lastt*colval(r->cext,BLU));
446                multcolor(cumval, ctmp);
447                addcolor(r->rcol, cumval);      /* sum into ray result */
444          }
445          samplendx = oldsampndx;
446   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines