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

Comparing ray/src/util/rsensor.c (file contents):
Revision 2.5 by greg, Fri Apr 11 22:06:04 2008 UTC vs.
Revision 2.6 by greg, Sat Dec 13 00:44:05 2008 UTC

# Line 84 | Line 84 | main(
84          progname = argv[0];
85                                  /* set up rendering defaults */
86          rand_samp = 1;
87 <        dstrsrc = 0.5;
87 >        dstrsrc = 0.65;
88          srcsizerat = 0.1;
89          directrelay = 3;
90          ambounce = 1;
# Line 103 | Line 103 | main(
103                          if (!ray_pnprocs) {
104                                  over_options();
105                                  if (doheader) { /* print header */
106 +                                        newheader("RADIANCE", stdout);
107                                          printargs(argc, argv, stdout);
108                                          fputformat("ascii", stdout);
109                                          putchar('\n');
# Line 461 | Line 462 | comp_sensor(
462          int     nt, np;
463          COLOR   vsum;
464          RAY     rr;
465 +        double  sf;
466          int     i, j;
467                                                  /* set view */
468          ourview.type = VT_ANG;
# Line 471 | Line 473 | comp_sensor(
473                  error(USER, err);
474                                                  /* assign probability table */
475          init_ptable(sfile);
476 <                                                /* do Monte Carlo sampling */
476 >                                                /* stratified MC sampling */
477          setcolor(vsum, .0f, .0f, .0f);
478          nt = (int)(sqrt((double)nsamps*ntheta/nphi) + .5);
479          np = nsamps/nt;
480 +        sf = gscale/nsamps;
481          for (i = 0; i < nt; i++)
482                  for (j = 0; j < np; j++) {
483                          VCOPY(rr.rorg, ourview.vp);
# Line 483 | Line 486 | comp_sensor(
486                                  VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore);
487                          rr.rmax = .0;
488                          rayorigin(&rr, PRIMARY, NULL, NULL);
489 +                        scalecolor(rr.rcoef, sf);
490                          if (ray_pqueue(&rr) == 1)
491                                  addcolor(vsum, rr.rcol);
492                  }
493 <                                                /* finish MC calculation */
494 <        while (ray_presult(&rr, 0) > 0)
495 <                addcolor(vsum, rr.rcol);
496 <        scalecolor(vsum, gscale/(nt*np));
497 <                                                /* compute direct component */
493 >                                                /* remaining rays pure MC */
494 >        for (i = nsamps - nt*np; i-- > 0; ) {
495 >                VCOPY(rr.rorg, ourview.vp);
496 >                get_direc(rr.rdir, frandom(), frandom());
497 >                if (ourview.vfore > FTINY)
498 >                        VSUM(rr.rorg, rr.rorg, rr.rdir, ourview.vfore);
499 >                rr.rmax = .0;
500 >                rayorigin(&rr, PRIMARY, NULL, NULL);
501 >                scalecolor(rr.rcoef, sf);
502 >                if (ray_pqueue(&rr) == 1)
503 >                        addcolor(vsum, rr.rcol);
504 >        }
505 >                                                /* scale partial result */
506 >        scalecolor(vsum, sf);
507 >                                                /* add direct component */
508          for (i = ndirs; i-- > 0; ) {
509                  SRCINDEX        si;
510                  initsrcindex(&si);
511                  while (srcray(&rr, NULL, &si)) {
512 <                        double  d = sens_val(rr.rdir);
513 <                        if (d <= FTINY)
512 >                        sf = sens_val(rr.rdir);
513 >                        if (sf <= FTINY)
514                                  continue;
515 <                        d *= si.dom/ndirs;
516 <                        scalecolor(rr.rcoef, d);
515 >                        sf *= si.dom/ndirs;
516 >                        scalecolor(rr.rcoef, sf);
517                          if (ray_pqueue(&rr) == 1) {
518                                  multcolor(rr.rcol, rr.rcoef);
519                                  addcolor(vsum, rr.rcol);
520                          }
521                  }
522          }
523 <                                                /* finish direct calculation */
523 >                                                /* finish our calculation */
524          while (ray_presult(&rr, 0) > 0) {
525                  multcolor(rr.rcol, rr.rcoef);
526                  addcolor(vsum, rr.rcol);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines