| 135 |
|
FVECT pdir; |
| 136 |
|
double tomega, srchrad; |
| 137 |
|
double tomsum, tomsurr; |
| 138 |
< |
COLOR vpeak, vsurr; |
| 138 |
> |
COLOR vpeak, vsurr, btdiff; |
| 139 |
|
double vypeak; |
| 140 |
|
int i, ns; |
| 141 |
|
SDError ec; |
| 192 |
|
vypeak += psamp[i].vy; |
| 193 |
|
++ns; |
| 194 |
|
} |
| 195 |
< |
if (tomsurr <= FTINY) /* no surround implies no peak */ |
| 195 |
> |
if (tomsurr < 0.2*tomsum) /* insufficient surround? */ |
| 196 |
|
return; |
| 197 |
– |
if ((vypeak/ns - (ndp->vray[2] > 0 ? ndp->sd->tLambFront.cieY |
| 198 |
– |
: ndp->sd->tLambBack.cieY)*(1./PI))*tomsum < .0005) |
| 199 |
– |
return; /* < 0.05% transmission */ |
| 200 |
– |
copycolor(ndp->cthru, vpeak); /* already scaled by omega */ |
| 201 |
– |
multcolor(ndp->cthru, ndp->pr->pcol); /* modify by pattern */ |
| 197 |
|
scalecolor(vsurr, 1./tomsurr); /* surround is avg. BTDF */ |
| 198 |
+ |
if (ndp->vray[2] > 0) /* get diffuse BTDF */ |
| 199 |
+ |
cvt_sdcolor(btdiff, &ndp->sd->tLambFront); |
| 200 |
+ |
else |
| 201 |
+ |
cvt_sdcolor(btdiff, &ndp->sd->tLambBack); |
| 202 |
+ |
scalecolor(btdiff, (1./PI)); |
| 203 |
+ |
for (i = 3; i--; ) { /* remove diffuse contrib. */ |
| 204 |
+ |
if ((colval(vpeak,i) -= tomsum*colval(btdiff,i)) < 0) |
| 205 |
+ |
colval(vpeak,i) = 0; |
| 206 |
+ |
if ((colval(vsurr,i) -= colval(btdiff,i)) < 0) |
| 207 |
+ |
colval(vsurr,i) = 0; |
| 208 |
+ |
} |
| 209 |
+ |
if (bright(vpeak) < .0005) /* < 0.05% specular? */ |
| 210 |
+ |
return; |
| 211 |
+ |
multcolor(vsurr, ndp->pr->pcol); /* modify by color */ |
| 212 |
+ |
multcolor(vpeak, ndp->pr->pcol); |
| 213 |
+ |
copycolor(ndp->cthru, vpeak); |
| 214 |
|
copycolor(ndp->cthru_surr, vsurr); |
| 204 |
– |
multcolor(ndp->cthru_surr, ndp->pr->pcol); |
| 215 |
|
return; |
| 216 |
|
baderror: |
| 217 |
|
objerror(ndp->mp, USER, transSDError(ec)); |