48 |
|
CUBE thescene; /* our scene */ |
49 |
|
OBJECT nsceneobjs; /* number of objects in our scene */ |
50 |
|
|
51 |
+ |
extern RGBPRIMP out_prims; /* output color primitives (NULL if spectral) */ |
52 |
+ |
|
53 |
|
int dimlist[MAXDIM]; /* sampling dimensions */ |
54 |
|
int ndims = 0; /* number of sampling dimensions */ |
55 |
|
int samplendx; /* sample index number */ |
94 |
|
int backvis = 1; /* back face visibility */ |
95 |
|
|
96 |
|
int maxdepth = 7; /* maximum recursion depth */ |
97 |
< |
double minweight = 1e-3; /* minimum ray weight */ |
97 |
> |
double minweight = 1e-4; /* minimum ray weight */ |
98 |
|
|
99 |
|
char *ambfile = NULL; /* ambient file name */ |
100 |
|
COLOR ambval = BLKCOLOR; /* ambient value */ |
342 |
|
if ((pa < .99) | (pa > 1.01)) |
343 |
|
fputaspect(pa, stdout); |
344 |
|
fputnow(stdout); |
345 |
< |
fputprims(stdprims, stdout); |
346 |
< |
fputformat(COLRFMT, stdout); |
347 |
< |
putchar('\n'); |
345 |
> |
if (out_prims == xyzprims) { |
346 |
> |
fputformat(CIEFMT, stdout); |
347 |
> |
} else { |
348 |
> |
fputprims(out_prims, stdout); |
349 |
> |
fputformat(COLRFMT, stdout); |
350 |
> |
} |
351 |
> |
putchar('\n'); /* close header */ |
352 |
|
if (zout != NULL) |
353 |
|
sprintf(cp=fbuf, zout, seq); |
354 |
|
else |
384 |
|
char *oldfile |
385 |
|
) |
386 |
|
{ |
387 |
+ |
const int srcdrawing = /* manually draw tiny light sources? */ |
388 |
+ |
(directvis && dblur <= FTINY && (mblur <= FTINY) | !lastview.type); |
389 |
|
COLOR *scanbar[MAXDIV+1]; /* scanline arrays of pixel values */ |
390 |
|
float *zbar[MAXDIV+1]; /* z values */ |
391 |
|
char *sampdens; /* previous sample density */ |
452 |
|
signal(SIGCONT, report); |
453 |
|
#endif |
454 |
|
ypos = vres-1 - i; /* initialize sampling */ |
455 |
< |
if (directvis) |
455 |
> |
if (srcdrawing) |
456 |
|
init_drawsources(psample); |
457 |
|
fillscanline(scanbar[0], zbar[0], sampdens, hres, ypos, hstep); |
458 |
|
/* compute scanlines */ |
473 |
|
hres, ypos, hstep); |
474 |
|
/* fill bar */ |
475 |
|
fillscanbar(scanbar, zbar, hres, ypos, ystep); |
476 |
< |
if (directvis) /* add bitty sources */ |
477 |
< |
drawsources(scanbar, zbar, 0, hres, ypos, ystep); |
476 |
> |
if (srcdrawing) /* add bitty sources */ |
477 |
> |
drawsources((COLORV **)scanbar, zbar, 0, hres, ypos, ystep); |
478 |
|
/* write it out */ |
479 |
|
#ifdef SIGCONT |
480 |
|
signal(SIGCONT, SIG_IGN); /* don't interrupt writes */ |
668 |
|
int y |
669 |
|
) |
670 |
|
{ |
671 |
< |
extern void SDsquare2disk(double ds[2], double seedx, double seedy); |
671 |
> |
static COLORMAT xyz2myrgbmat; |
672 |
|
RAY thisray; |
673 |
|
FVECT lorg, ldir; |
674 |
< |
double hpos, vpos, vdist, lmax; |
674 |
> |
double hpos, vpos, lmax; |
675 |
|
int i; |
676 |
|
/* compute view ray */ |
677 |
|
setcolor(col, 0.0, 0.0, 0.0); |
680 |
|
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
681 |
|
&ourview, hpos, vpos)) < -FTINY) |
682 |
|
return(0.0); |
675 |
– |
|
676 |
– |
vdist = ourview.vdist; |
683 |
|
/* set pixel index */ |
684 |
|
samplendx = pixnumber(x,y,hres,vres); |
685 |
|
/* optional motion blur */ |
694 |
|
} |
695 |
|
if (normalize(thisray.rdir) == 0.0) |
696 |
|
return(0.0); |
691 |
– |
vdist = (1.-d)*vdist + d*lastview.vdist; |
697 |
|
} |
698 |
< |
/* optional depth-of-field */ |
699 |
< |
if (dblur > FTINY) { |
700 |
< |
double vc, df[2]; |
696 |
< |
/* random point on disk */ |
697 |
< |
SDsquare2disk(df, frandom(), frandom()); |
698 |
< |
df[0] *= .5*dblur; |
699 |
< |
df[1] *= .5*dblur; |
700 |
< |
if ((ourview.type == VT_PER) | (ourview.type == VT_PAR)) { |
701 |
< |
double adj = 1.0; |
702 |
< |
if (ourview.type == VT_PER) |
703 |
< |
adj /= DOT(thisray.rdir, ourview.vdir); |
704 |
< |
df[0] /= sqrt(ourview.hn2); |
705 |
< |
df[1] /= sqrt(ourview.vn2); |
706 |
< |
for (i = 3; i--; ) { |
707 |
< |
vc = ourview.vp[i] + adj*vdist*thisray.rdir[i]; |
708 |
< |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
709 |
< |
df[1]*ourview.vvec[i] ; |
710 |
< |
thisray.rdir[i] = vc - thisray.rorg[i]; |
711 |
< |
} |
712 |
< |
} else { /* non-standard view case */ |
713 |
< |
double dfd = PI/4.*dblur*(.5 - frandom()); |
714 |
< |
if ((ourview.type != VT_ANG) & (ourview.type != VT_PLS)) { |
715 |
< |
if (ourview.type != VT_CYL) |
716 |
< |
df[0] /= sqrt(ourview.hn2); |
717 |
< |
df[1] /= sqrt(ourview.vn2); |
718 |
< |
} |
719 |
< |
for (i = 3; i--; ) { |
720 |
< |
vc = ourview.vp[i] + vdist*thisray.rdir[i]; |
721 |
< |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
722 |
< |
df[1]*ourview.vvec[i] + |
723 |
< |
dfd*ourview.vdir[i] ; |
724 |
< |
thisray.rdir[i] = vc - thisray.rorg[i]; |
725 |
< |
} |
726 |
< |
} |
727 |
< |
if (normalize(thisray.rdir) == 0.0) |
728 |
< |
return(0.0); |
729 |
< |
} |
698 |
> |
/* depth-of-field */ |
699 |
> |
if (!jitteraperture(thisray.rorg, thisray.rdir, &ourview, dblur)) |
700 |
> |
return(0.0); |
701 |
|
|
702 |
|
rayorigin(&thisray, PRIMARY, NULL, NULL); |
703 |
|
|
704 |
|
rayvalue(&thisray); /* trace ray */ |
705 |
|
|
706 |
< |
copycolor(col, thisray.rcol); /* return color */ |
706 |
> |
if (out_prims == stdprims) { /* return color */ |
707 |
> |
scolor_rgb(col, thisray.rcol); |
708 |
> |
} else if (out_prims == xyzprims) { |
709 |
> |
scolor_cie(col, thisray.rcol); |
710 |
> |
scalecolor(col, WHTEFFICACY); |
711 |
> |
} else if (NCSAMP > 3) { |
712 |
> |
COLOR xyz; |
713 |
> |
if (xyz2myrgbmat[0][0] == 0) |
714 |
> |
compxyz2rgbWBmat(xyz2myrgbmat, out_prims); |
715 |
> |
scolor_cie(xyz, thisray.rcol); |
716 |
> |
colortrans(col, xyz2myrgbmat, xyz); |
717 |
> |
clipgamut(col, xyz[CIEY], CGAMUT_LOWER, cblack, cwhite); |
718 |
> |
} else |
719 |
> |
copycolor(col, thisray.rcol); |
720 |
|
|
721 |
|
return(raydistance(&thisray)); /* return distance */ |
722 |
|
} |