30 |
|
OBJECT *obuffer; /* object id at each pixel */ |
31 |
|
short *xmbuffer; /* x motion at each pixel */ |
32 |
|
short *ymbuffer; /* y motion at each pixel */ |
33 |
< |
BYTE *abuffer; /* accuracy at each pixel */ |
34 |
< |
BYTE *sbuffer; /* sample count per pixel */ |
33 |
> |
uby8 *abuffer; /* accuracy at each pixel */ |
34 |
> |
uby8 *sbuffer; /* sample count per pixel */ |
35 |
|
|
36 |
|
VIEW vwprev; /* last frame's view */ |
37 |
|
COLOR *cprev; /* last frame colors */ |
38 |
|
float *zprev; /* last frame depth */ |
39 |
|
OBJECT *oprev; /* last frame objects */ |
40 |
< |
BYTE *aprev; /* last frame accuracy */ |
40 |
> |
uby8 *aprev; /* last frame accuracy */ |
41 |
|
|
42 |
|
float *cerrmap; /* conspicuous error map */ |
43 |
|
COLOR *val2map; /* value-squared map for variance */ |
54 |
|
static void init_frame_sample(void); |
55 |
|
|
56 |
|
|
57 |
+ |
#if 0 |
58 |
|
extern void |
59 |
|
write_map( /* write out float map (debugging) */ |
60 |
|
float *mp, |
80 |
|
} |
81 |
|
fclose(fp); |
82 |
|
} |
83 |
+ |
#endif |
84 |
|
|
85 |
|
|
86 |
|
static void |
107 |
|
error(USER, errmsg); |
108 |
|
} |
109 |
|
if (cbuffer == NULL) { |
110 |
+ |
int n; |
111 |
|
/* compute resolution and allocate */ |
112 |
|
switch (sscanf(vval(RESOLUTION), "%d %d %lf", |
113 |
|
&hres, &vres, &pixaspect)) { |
131 |
|
obuffer = (OBJECT *)malloc(sizeof(OBJECT)*hres*vres); |
132 |
|
xmbuffer = (short *)malloc(sizeof(short)*hres*vres); |
133 |
|
ymbuffer = (short *)malloc(sizeof(short)*hres*vres); |
134 |
< |
abuffer = (BYTE *)calloc(hres*vres, sizeof(BYTE)); |
135 |
< |
sbuffer = (BYTE *)calloc(hres*vres, sizeof(BYTE)); |
134 |
> |
abuffer = (uby8 *)calloc(hres*vres, sizeof(uby8)); |
135 |
> |
sbuffer = (uby8 *)calloc(hres*vres, sizeof(uby8)); |
136 |
|
cprev = (COLOR *)malloc(sizeof(COLOR)*hres*vres); |
137 |
|
zprev = (float *)malloc(sizeof(float)*hres*vres); |
138 |
|
oprev = (OBJECT *)malloc(sizeof(OBJECT)*hres*vres); |
139 |
< |
aprev = (BYTE *)malloc(sizeof(BYTE)*hres*vres); |
139 |
> |
aprev = (uby8 *)malloc(sizeof(uby8)*hres*vres); |
140 |
|
if ((cbuffer==NULL) | (zbuffer==NULL) | (obuffer==NULL) | |
141 |
|
(xmbuffer==NULL) | (ymbuffer==NULL) | |
142 |
|
(abuffer==NULL) | (sbuffer==NULL) | |
143 |
|
(cprev==NULL) | (zprev == NULL) | |
144 |
|
(oprev==NULL) | (aprev==NULL)) |
145 |
|
error(SYSTEM, "out of memory in init_frame"); |
146 |
+ |
for (n = hres*vres; n--; ) { |
147 |
+ |
zprev[n] = -1.f; |
148 |
+ |
oprev[n] = OVOID; |
149 |
+ |
} |
150 |
|
frm_stop = getTime() + rtperfrm; |
151 |
|
} else { |
152 |
|
COLOR *cp; /* else just swap buffers */ |
153 |
|
float *fp; |
154 |
|
OBJECT *op; |
155 |
< |
BYTE *bp; |
155 |
> |
uby8 *bp; |
156 |
|
cp = cprev; cprev = cbuffer; cbuffer = cp; |
157 |
|
fp = zprev; zprev = zbuffer; zbuffer = fp; |
158 |
|
op = oprev; oprev = obuffer; obuffer = op; |
159 |
|
bp = aprev; aprev = abuffer; abuffer = bp; |
160 |
< |
memset(abuffer, '\0', sizeof(BYTE)*hres*vres); |
161 |
< |
memset(sbuffer, '\0', sizeof(BYTE)*hres*vres); |
160 |
> |
memset(abuffer, '\0', sizeof(uby8)*hres*vres); |
161 |
> |
memset(sbuffer, '\0', sizeof(uby8)*hres*vres); |
162 |
|
frm_stop += rtperfrm; |
163 |
|
} |
164 |
|
cerrmap = NULL; |
376 |
|
if (!sample_here(x, y)) { /* just cast */ |
377 |
|
rayorigin(&ir, PRIMARY, NULL, NULL); |
378 |
|
if (!localhit(&ir, &thescene)) { |
379 |
< |
if (ir.ro != &Aftplane) |
380 |
< |
sourcehit(&ir); |
379 |
> |
if (ir.ro != &Aftplane && sourcehit(&ir)) { |
380 |
> |
rayshade(&ir, ir.ro->omod); |
381 |
> |
rayparticipate(&ir); |
382 |
> |
} |
383 |
|
copycolor(cbuffer[n], ir.rcol); |
384 |
|
zbuffer[n] = ir.rot; |
385 |
|
obuffer[n] = ir.robj; |
408 |
|
zbuffer[n] = ir.rot; |
409 |
|
obuffer[n] = ir.robj; |
410 |
|
sbuffer[n] = 1; |
411 |
< |
if (ir.rot >= FHUGE) |
411 |
> |
if (ir.rot >= 0.99*FHUGE) |
412 |
|
abuffer[n] = ADISTANT; |
413 |
|
else { |
414 |
|
abuffer[n] = ALOWQ; |
461 |
|
|
462 |
|
if (obj == OVOID) |
463 |
|
return(0); |
464 |
< |
op = objptr(obj); |
465 |
< |
if ((op->otype == OBJ_INSTANCE) & (op->omod == OVOID)) |
464 |
> |
op = objptr(obj); /* search for material */ |
465 |
> |
if (op->omod == OVOID) |
466 |
|
return(0); |
467 |
< |
/* search for material */ |
468 |
< |
do { |
469 |
< |
if (op->omod == OVOID || ofun[op->otype].flags & T_X) |
461 |
< |
return(0); |
462 |
< |
op = objptr(op->omod); |
463 |
< |
} while (!ismaterial(op->otype)); |
467 |
> |
op = findmaterial(objptr(op->omod)); |
468 |
> |
if (op == NULL) |
469 |
> |
return(0); |
470 |
|
/* |
471 |
|
* Since this routine is called to compute the difference |
472 |
|
* from rendering with and without interreflections, |
480 |
|
if (lv[0] == op->oname[0] && |
481 |
|
!strcmp(lv+1, op->oname+1)) |
482 |
|
break; |
483 |
< |
if ((lv != NULL) != hirendparams.ambincl) |
483 |
> |
if ((lv != NULL) ^ hirendparams.ambincl) |
484 |
|
return(0); |
485 |
|
} |
486 |
|
switch (op->otype) { |
584 |
|
extern void |
585 |
|
comp_frame_error(void) /* initialize frame error values */ |
586 |
|
{ |
587 |
< |
BYTE *edone = NULL; |
587 |
> |
uby8 *edone = NULL; |
588 |
|
COLOR objamb; |
589 |
|
double eest; |
590 |
|
int neigh[NSAMPOK]; |
608 |
|
* error should be less than the ambient value divided |
609 |
|
* by the returned ray value -- we take half of this. |
610 |
|
*/ |
611 |
< |
edone = (BYTE *)calloc(hres*vres, sizeof(BYTE)); |
611 |
> |
edone = (uby8 *)calloc(hres*vres, sizeof(uby8)); |
612 |
|
for (y = vres; y--; ) |
613 |
|
for (x = hres; x--; ) { |
614 |
|
n = fndx(x, y); |
664 |
|
init_frame(void) /* render base (low quality) frame */ |
665 |
|
{ |
666 |
|
int restart; |
661 |
– |
|
667 |
|
/* allocate/swap buffers */ |
668 |
|
next_frame(); |
669 |
|
/* check rendering status */ |
670 |
|
restart = (!nobjects || vdef(MOVE)); |
671 |
|
if (!restart && curparams != &lorendparams && nprocs > 1) |
672 |
|
restart = -1; |
668 |
– |
if (restart > 0) { |
669 |
– |
if (nprocs > 1) |
670 |
– |
ray_pdone(1); |
671 |
– |
else |
672 |
– |
ray_done(1); |
673 |
– |
} |
673 |
|
/* post low quality parameters */ |
674 |
|
if (curparams != &lorendparams) |
675 |
|
ray_restore(curparams = &lorendparams); |
701 |
|
init_frame_sample(); |
702 |
|
/* initialize frame error */ |
703 |
|
comp_frame_error(); |
704 |
< |
return; |
704 |
> |
#if 0 |
705 |
|
{ |
706 |
|
float *ebuf = (float *)malloc(sizeof(float)*hres*vres); |
707 |
|
char fnm[256]; |
713 |
|
write_map(ebuf, fnm); |
714 |
|
free((void *)ebuf); |
715 |
|
} |
716 |
+ |
#endif |
717 |
|
} |
718 |
|
|
719 |
|
|
904 |
|
int y; |
905 |
|
/* open output picture */ |
906 |
|
sprintf(pfname, vval(BASENAME), fcur); |
907 |
< |
strcat(pfname, ".pic"); |
907 |
> |
strcat(pfname, ".hdr"); |
908 |
|
fp = fopen(pfname, "w"); |
909 |
|
if (fp == NULL) { |
910 |
|
sprintf(errmsg, "cannot open output frame \"%s\"", pfname); |