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.27 by gregl, Fri Aug 15 10:24:24 1997 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines