| 14 |
|
#include "otypes.h" |
| 15 |
|
#include "otspecial.h" |
| 16 |
|
#include "random.h" |
| 17 |
+ |
#include "pmap.h" |
| 18 |
|
|
| 19 |
|
#define MAXCSET ((MAXSET+1)*2-1) /* maximum check set size */ |
| 20 |
|
|
| 36 |
|
static void checkset(OBJECT *os, OBJECT *cs); |
| 37 |
|
|
| 38 |
|
|
| 39 |
< |
extern int |
| 39 |
> |
int |
| 40 |
|
rayorigin( /* start new ray from old one */ |
| 41 |
|
RAY *r, |
| 42 |
|
int rt, |
| 107 |
|
return(-1); |
| 108 |
|
if (r->crtype & SHADOW) /* shadow commitment */ |
| 109 |
|
return(0); |
| 110 |
+ |
/* ambient in photon map? */ |
| 111 |
+ |
if (ro != NULL && ro->crtype & AMBIENT) { |
| 112 |
+ |
if (causticPhotonMapping) |
| 113 |
+ |
return(-1); |
| 114 |
+ |
if (photonMapping && rt != TRANS) |
| 115 |
+ |
return(-1); |
| 116 |
+ |
} |
| 117 |
|
if (maxdepth <= 0 && rc != NULL) { /* Russian roulette */ |
| 118 |
|
if (minweight <= 0.0) |
| 119 |
|
error(USER, "zero ray weight in Russian roulette"); |
| 132 |
|
} |
| 133 |
|
|
| 134 |
|
|
| 135 |
< |
extern void |
| 135 |
> |
void |
| 136 |
|
rayclear( /* clear a ray for (re)evaluation */ |
| 137 |
|
RAY *r |
| 138 |
|
) |
| 151 |
|
} |
| 152 |
|
|
| 153 |
|
|
| 154 |
< |
extern void |
| 154 |
> |
void |
| 155 |
|
raytrace( /* trace a ray and compute its value */ |
| 156 |
|
RAY *r |
| 157 |
|
) |
| 171 |
|
} |
| 172 |
|
|
| 173 |
|
|
| 174 |
< |
extern void |
| 174 |
> |
void |
| 175 |
|
raycont( /* check for clipped object and continue */ |
| 176 |
|
RAY *r |
| 177 |
|
) |
| 182 |
|
} |
| 183 |
|
|
| 184 |
|
|
| 185 |
< |
extern void |
| 185 |
> |
void |
| 186 |
|
raytrans( /* transmit ray as is */ |
| 187 |
|
RAY *r |
| 188 |
|
) |
| 189 |
|
{ |
| 190 |
|
RAY tr; |
| 191 |
|
|
| 192 |
< |
if (rayorigin(&tr, TRANS, r, NULL) == 0) { |
| 193 |
< |
VCOPY(tr.rdir, r->rdir); |
| 194 |
< |
rayvalue(&tr); |
| 195 |
< |
copycolor(r->rcol, tr.rcol); |
| 196 |
< |
r->rt = r->rot + tr.rt; |
| 189 |
< |
} |
| 192 |
> |
rayorigin(&tr, TRANS, r, NULL); /* always continue */ |
| 193 |
> |
VCOPY(tr.rdir, r->rdir); |
| 194 |
> |
rayvalue(&tr); |
| 195 |
> |
copycolor(r->rcol, tr.rcol); |
| 196 |
> |
r->rt = r->rot + tr.rt; |
| 197 |
|
} |
| 198 |
|
|
| 199 |
|
|
| 200 |
< |
extern int |
| 200 |
> |
int |
| 201 |
|
rayshade( /* shade ray r with material mod */ |
| 202 |
|
RAY *r, |
| 203 |
|
int mod |
| 232 |
|
} |
| 233 |
|
|
| 234 |
|
|
| 235 |
< |
extern void |
| 235 |
> |
void |
| 236 |
|
rayparticipate( /* compute ray medium participation */ |
| 237 |
|
RAY *r |
| 238 |
|
) |
| 256 |
|
multcolor(r->rcol, ce); /* path extinction */ |
| 257 |
|
if (r->crtype & SHADOW || intens(r->albedo) <= FTINY) |
| 258 |
|
return; /* no scattering */ |
| 259 |
< |
setcolor(ca, |
| 260 |
< |
colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)), |
| 261 |
< |
colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)), |
| 262 |
< |
colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU))); |
| 263 |
< |
addcolor(r->rcol, ca); /* ambient in scattering */ |
| 259 |
> |
|
| 260 |
> |
/* PMAP: indirect inscattering accounted for by volume photons? */ |
| 261 |
> |
if (!volumePhotonMapping) { |
| 262 |
> |
setcolor(ca, |
| 263 |
> |
colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)), |
| 264 |
> |
colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)), |
| 265 |
> |
colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU))); |
| 266 |
> |
addcolor(r->rcol, ca); /* ambient in scattering */ |
| 267 |
> |
} |
| 268 |
> |
|
| 269 |
|
srcscatter(r); /* source in scattering */ |
| 270 |
|
} |
| 271 |
|
|
| 272 |
|
|
| 273 |
< |
extern void |
| 273 |
> |
void |
| 274 |
|
raytexture( /* get material modifiers */ |
| 275 |
|
RAY *r, |
| 276 |
|
OBJECT mod |
| 295 |
|
} |
| 296 |
|
|
| 297 |
|
|
| 298 |
< |
extern int |
| 298 |
> |
int |
| 299 |
|
raymixture( /* mix modifiers */ |
| 300 |
|
RAY *r, |
| 301 |
|
OBJECT fore, |
| 355 |
|
} |
| 356 |
|
|
| 357 |
|
|
| 358 |
< |
extern double |
| 358 |
> |
double |
| 359 |
|
raydist( /* compute (cumulative) ray distance */ |
| 360 |
|
const RAY *r, |
| 361 |
|
int flags |
| 371 |
|
} |
| 372 |
|
|
| 373 |
|
|
| 374 |
< |
extern void |
| 374 |
> |
void |
| 375 |
|
raycontrib( /* compute (cumulative) ray contribution */ |
| 376 |
|
RREAL rc[3], |
| 377 |
|
const RAY *r, |
| 397 |
|
} |
| 398 |
|
|
| 399 |
|
|
| 400 |
< |
extern double |
| 400 |
> |
double |
| 401 |
|
raynormal( /* compute perturbed normal for ray */ |
| 402 |
|
FVECT norm, |
| 403 |
|
RAY *r |
| 433 |
|
} |
| 434 |
|
|
| 435 |
|
|
| 436 |
< |
extern void |
| 436 |
> |
void |
| 437 |
|
newrayxf( /* get new tranformation matrix for ray */ |
| 438 |
|
RAY *r |
| 439 |
|
) |
| 471 |
|
} |
| 472 |
|
|
| 473 |
|
|
| 474 |
< |
extern void |
| 474 |
> |
void |
| 475 |
|
flipsurface( /* reverse surface orientation */ |
| 476 |
|
RAY *r |
| 477 |
|
) |
| 486 |
|
} |
| 487 |
|
|
| 488 |
|
|
| 489 |
< |
extern void |
| 489 |
> |
void |
| 490 |
|
rayhit( /* standard ray hit test */ |
| 491 |
|
OBJECT *oset, |
| 492 |
|
RAY *r |
| 503 |
|
} |
| 504 |
|
|
| 505 |
|
|
| 506 |
< |
extern int |
| 506 |
> |
int |
| 507 |
|
localhit( /* check for hit in the octree */ |
| 508 |
|
RAY *r, |
| 509 |
|
CUBE *scene |