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 (r->crtype & AMBIENT && photonMapping) |
112 |
+ |
return(-1); |
113 |
|
if (maxdepth <= 0 && rc != NULL) { /* Russian roulette */ |
114 |
|
if (minweight <= 0.0) |
115 |
|
error(USER, "zero ray weight in Russian roulette"); |
128 |
|
} |
129 |
|
|
130 |
|
|
131 |
< |
extern void |
131 |
> |
void |
132 |
|
rayclear( /* clear a ray for (re)evaluation */ |
133 |
|
RAY *r |
134 |
|
) |
147 |
|
} |
148 |
|
|
149 |
|
|
150 |
< |
extern void |
150 |
> |
void |
151 |
|
raytrace( /* trace a ray and compute its value */ |
152 |
|
RAY *r |
153 |
|
) |
167 |
|
} |
168 |
|
|
169 |
|
|
170 |
< |
extern void |
170 |
> |
void |
171 |
|
raycont( /* check for clipped object and continue */ |
172 |
|
RAY *r |
173 |
|
) |
178 |
|
} |
179 |
|
|
180 |
|
|
181 |
< |
extern void |
181 |
> |
void |
182 |
|
raytrans( /* transmit ray as is */ |
183 |
|
RAY *r |
184 |
|
) |
185 |
|
{ |
186 |
|
RAY tr; |
187 |
|
|
188 |
< |
if (rayorigin(&tr, TRANS, r, NULL) == 0) { |
189 |
< |
VCOPY(tr.rdir, r->rdir); |
190 |
< |
rayvalue(&tr); |
191 |
< |
copycolor(r->rcol, tr.rcol); |
192 |
< |
r->rt = r->rot + tr.rt; |
189 |
< |
} |
188 |
> |
rayorigin(&tr, TRANS, r, NULL); /* always continue */ |
189 |
> |
VCOPY(tr.rdir, r->rdir); |
190 |
> |
rayvalue(&tr); |
191 |
> |
copycolor(r->rcol, tr.rcol); |
192 |
> |
r->rt = r->rot + tr.rt; |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
< |
extern int |
196 |
> |
int |
197 |
|
rayshade( /* shade ray r with material mod */ |
198 |
|
RAY *r, |
199 |
|
int mod |
228 |
|
} |
229 |
|
|
230 |
|
|
231 |
< |
extern void |
231 |
> |
void |
232 |
|
rayparticipate( /* compute ray medium participation */ |
233 |
|
RAY *r |
234 |
|
) |
252 |
|
multcolor(r->rcol, ce); /* path extinction */ |
253 |
|
if (r->crtype & SHADOW || intens(r->albedo) <= FTINY) |
254 |
|
return; /* no scattering */ |
255 |
< |
setcolor(ca, |
256 |
< |
colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)), |
257 |
< |
colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)), |
258 |
< |
colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU))); |
259 |
< |
addcolor(r->rcol, ca); /* ambient in scattering */ |
255 |
> |
|
256 |
> |
/* PMAP: indirect inscattering accounted for by volume photons? */ |
257 |
> |
if (!volumePhotonMapping) { |
258 |
> |
setcolor(ca, |
259 |
> |
colval(r->albedo,RED)*colval(ambval,RED)*(1.-colval(ce,RED)), |
260 |
> |
colval(r->albedo,GRN)*colval(ambval,GRN)*(1.-colval(ce,GRN)), |
261 |
> |
colval(r->albedo,BLU)*colval(ambval,BLU)*(1.-colval(ce,BLU))); |
262 |
> |
addcolor(r->rcol, ca); /* ambient in scattering */ |
263 |
> |
} |
264 |
> |
|
265 |
|
srcscatter(r); /* source in scattering */ |
266 |
|
} |
267 |
|
|
268 |
|
|
269 |
< |
extern void |
269 |
> |
void |
270 |
|
raytexture( /* get material modifiers */ |
271 |
|
RAY *r, |
272 |
|
OBJECT mod |
291 |
|
} |
292 |
|
|
293 |
|
|
294 |
< |
extern int |
294 |
> |
int |
295 |
|
raymixture( /* mix modifiers */ |
296 |
|
RAY *r, |
297 |
|
OBJECT fore, |
351 |
|
} |
352 |
|
|
353 |
|
|
354 |
< |
extern double |
354 |
> |
double |
355 |
|
raydist( /* compute (cumulative) ray distance */ |
356 |
|
const RAY *r, |
357 |
|
int flags |
367 |
|
} |
368 |
|
|
369 |
|
|
370 |
< |
extern void |
370 |
> |
void |
371 |
|
raycontrib( /* compute (cumulative) ray contribution */ |
372 |
|
RREAL rc[3], |
373 |
|
const RAY *r, |
393 |
|
} |
394 |
|
|
395 |
|
|
396 |
< |
extern double |
396 |
> |
double |
397 |
|
raynormal( /* compute perturbed normal for ray */ |
398 |
|
FVECT norm, |
399 |
|
RAY *r |
429 |
|
} |
430 |
|
|
431 |
|
|
432 |
< |
extern void |
432 |
> |
void |
433 |
|
newrayxf( /* get new tranformation matrix for ray */ |
434 |
|
RAY *r |
435 |
|
) |
467 |
|
} |
468 |
|
|
469 |
|
|
470 |
< |
extern void |
470 |
> |
void |
471 |
|
flipsurface( /* reverse surface orientation */ |
472 |
|
RAY *r |
473 |
|
) |
482 |
|
} |
483 |
|
|
484 |
|
|
485 |
< |
extern void |
485 |
> |
void |
486 |
|
rayhit( /* standard ray hit test */ |
487 |
|
OBJECT *oset, |
488 |
|
RAY *r |
499 |
|
} |
500 |
|
|
501 |
|
|
502 |
< |
extern int |
502 |
> |
int |
503 |
|
localhit( /* check for hit in the octree */ |
504 |
|
RAY *r, |
505 |
|
CUBE *scene |