| 10 |
|
#include "ray.h" |
| 11 |
|
#include "otypes.h" |
| 12 |
|
#include "rtotypes.h" |
| 13 |
+ |
#include "pmapmat.h" |
| 14 |
|
|
| 15 |
|
/* |
| 16 |
|
* This definition of glass provides for a quick calculation |
| 55 |
|
COLOR trans, refl; |
| 56 |
|
int hastexture, hastrans; |
| 57 |
|
double d, r1e, r1m; |
| 57 |
– |
double transtest, transdist; |
| 58 |
– |
double mirtest, mirdist; |
| 58 |
|
RAY p; |
| 59 |
|
int i; |
| 60 |
+ |
|
| 61 |
+ |
/* PMAP: skip refracted shadow or ambient ray if accounted for in |
| 62 |
+ |
photon map */ |
| 63 |
+ |
if (shadowRayInPmap(r) || ambRayInPmap(r)) |
| 64 |
+ |
return(1); |
| 65 |
|
/* check arguments */ |
| 66 |
|
if (m->oargs.nfargs == 3) |
| 67 |
|
rindex = RINDEX; /* default value of n */ |
| 86 |
|
raytexture(r, m->omod); |
| 87 |
|
if (r->rod < 0.0) /* reorient if necessary */ |
| 88 |
|
flipsurface(r); |
| 85 |
– |
mirtest = transtest = 0; |
| 86 |
– |
mirdist = transdist = r->rot; |
| 89 |
|
/* perturb normal */ |
| 90 |
|
if ( (hastexture = (DOT(r->pert,r->pert) > FTINY*FTINY)) ) { |
| 91 |
|
pdot = raynormal(pnorm, r); |
| 126 |
|
} |
| 127 |
|
} else { |
| 128 |
|
VCOPY(p.rdir, r->rdir); |
| 127 |
– |
transtest = 2; |
| 129 |
|
} |
| 130 |
|
rayvalue(&p); |
| 131 |
|
multcolor(p.rcol, p.rcoef); |
| 132 |
|
addcolor(r->rcol, p.rcol); |
| 133 |
< |
transtest *= bright(p.rcol); |
| 134 |
< |
transdist = r->rot + p.rt; |
| 133 |
> |
if (!hastexture || r->crtype & (SHADOW|AMBIENT)) |
| 134 |
> |
r->rxt = r->rot + raydistance(&p); |
| 135 |
|
} |
| 136 |
|
} |
| 137 |
< |
if (r->crtype & SHADOW) { /* skip reflected ray */ |
| 137 |
< |
r->rt = transdist; |
| 137 |
> |
if (r->crtype & SHADOW) /* skip reflected ray */ |
| 138 |
|
return(1); |
| 139 |
– |
} |
| 139 |
|
/* compute reflectance */ |
| 140 |
|
for (i = 0; i < 3; i++) { |
| 141 |
|
d = colval(mcolor, i); |
| 149 |
|
checknorm(p.rdir); |
| 150 |
|
rayvalue(&p); |
| 151 |
|
multcolor(p.rcol, p.rcoef); |
| 152 |
+ |
copycolor(r->mcol, p.rcol); |
| 153 |
|
addcolor(r->rcol, p.rcol); |
| 154 |
+ |
r->rmt = r->rot; |
| 155 |
|
if (r->ro != NULL && isflat(r->ro->otype) && |
| 156 |
< |
!hastexture | (r->crtype & AMBIENT)) { |
| 157 |
< |
mirtest = 2.0*bright(p.rcol); |
| 157 |
< |
mirdist = r->rot + p.rt; |
| 158 |
< |
} |
| 156 |
> |
!hastexture | (r->crtype & AMBIENT)) |
| 157 |
> |
r->rmt += raydistance(&p); |
| 158 |
|
} |
| 160 |
– |
/* check distance */ |
| 161 |
– |
d = bright(r->rcol); |
| 162 |
– |
if (transtest > d) |
| 163 |
– |
r->rt = transdist; |
| 164 |
– |
else if (mirtest > d) |
| 165 |
– |
r->rt = mirdist; |
| 159 |
|
return(1); |
| 160 |
|
} |