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

Comparing ray/src/cv/bsdfmesh.c (file contents):
Revision 2.35 by greg, Sat Jan 30 01:31:57 2016 UTC vs.
Revision 2.36 by greg, Sat Jan 30 17:34:00 2016 UTC

# Line 106 | Line 106 | dbl_cmp(const void *p1, const void *p2)
106          return(0);
107   }
108  
109 < /* Compute average BSDF peak from current DSF's */
109 > /* Conservative estimate of average BSDF value from current DSF's */
110   static void
111   comp_bsdf_spec(void)
112   {
# Line 117 | Line 117 | comp_bsdf_spec(void)
117          double          max_cost = 1.;
118          RBFNODE         *rbf;
119          FVECT           sdv;
120 <                                                /* grazing 25th percentile */
120 >                                                /* sort by incident altitude */
121          for (rbf = dsf_list; rbf != NULL; rbf = rbf->next)
122                  n++;
123          if (n >= 10)
# Line 131 | Line 131 | comp_bsdf_spec(void)
131          for (rbf = dsf_list; rbf != NULL; rbf = rbf->next)
132                  cost_list[n++] = rbf->invec[2]*input_orient;
133          qsort(cost_list, n, sizeof(double), dbl_cmp);
134 <        max_cost = cost_list[(n+3)/4];
134 >        max_cost = cost_list[(n+3)/4];          /* accept 25% nearest grazing */
135          free(cost_list);
136          n = 0;
137          for (rbf = dsf_list; rbf != NULL; rbf = rbf->next) {
# Line 141 | Line 141 | comp_bsdf_spec(void)
141                  sdv[0] = -rbf->invec[0];
142                  sdv[1] = -rbf->invec[1];
143                  sdv[2] = rbf->invec[2]*(2*(input_orient==output_orient) - 1);
144                this_rad = est_DSFrad(rbf, sdv);
144                  cosfact = COSF(sdv[2]);
145 +                this_rad = est_DSFrad(rbf, sdv);
146                  vest = eval_rbfrep(rbf, sdv) * cosfact *
147 <                                (2*M_PI) * this_rad*this_rad;
148 <                if (vest > rbf->vtotal)
147 >                                (2.*M_PI) * this_rad*this_rad;
148 >                if (vest > rbf->vtotal)         /* don't over-estimate energy */
149                          vest = rbf->vtotal;
150 <                vmod_sum += vest / cosfact;
150 >                vmod_sum += vest / cosfact;     /* remove cosine factor */
151                  rad_sum += this_rad;
152                  ++n;
153          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines