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 |
666 |
|
int y |
667 |
|
) |
668 |
|
{ |
669 |
+ |
static COLORMAT xyz2myrgbmat; |
670 |
|
RAY thisray; |
671 |
|
FVECT lorg, ldir; |
672 |
< |
double hpos, vpos, vdist, lmax; |
672 |
> |
double hpos, vpos, lmax; |
673 |
|
int i; |
674 |
|
/* compute view ray */ |
675 |
|
setcolor(col, 0.0, 0.0, 0.0); |
678 |
|
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
679 |
|
&ourview, hpos, vpos)) < -FTINY) |
680 |
|
return(0.0); |
674 |
– |
|
675 |
– |
vdist = ourview.vdist; |
681 |
|
/* set pixel index */ |
682 |
|
samplendx = pixnumber(x,y,hres,vres); |
683 |
|
/* optional motion blur */ |
692 |
|
} |
693 |
|
if (normalize(thisray.rdir) == 0.0) |
694 |
|
return(0.0); |
690 |
– |
vdist = (1.-d)*vdist + d*lastview.vdist; |
695 |
|
} |
696 |
< |
/* optional depth-of-field */ |
697 |
< |
if (dblur > FTINY) { |
698 |
< |
double vc, df[2]; |
695 |
< |
/* random point on disk */ |
696 |
< |
SDsquare2disk(df, frandom(), frandom()); |
697 |
< |
df[0] *= .5*dblur; |
698 |
< |
df[1] *= .5*dblur; |
699 |
< |
if ((ourview.type == VT_PER) | (ourview.type == VT_PAR)) { |
700 |
< |
double adj = 1.0; |
701 |
< |
if (ourview.type == VT_PER) |
702 |
< |
adj /= DOT(thisray.rdir, ourview.vdir); |
703 |
< |
df[0] /= sqrt(ourview.hn2); |
704 |
< |
df[1] /= sqrt(ourview.vn2); |
705 |
< |
for (i = 3; i--; ) { |
706 |
< |
vc = ourview.vp[i] + adj*vdist*thisray.rdir[i]; |
707 |
< |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
708 |
< |
df[1]*ourview.vvec[i] ; |
709 |
< |
thisray.rdir[i] = vc - thisray.rorg[i]; |
710 |
< |
} |
711 |
< |
} else { /* non-standard view case */ |
712 |
< |
double dfd = PI/4.*dblur*(.5 - frandom()); |
713 |
< |
if ((ourview.type != VT_ANG) & (ourview.type != VT_PLS)) { |
714 |
< |
if (ourview.type != VT_CYL) |
715 |
< |
df[0] /= sqrt(ourview.hn2); |
716 |
< |
df[1] /= sqrt(ourview.vn2); |
717 |
< |
} |
718 |
< |
for (i = 3; i--; ) { |
719 |
< |
vc = ourview.vp[i] + vdist*thisray.rdir[i]; |
720 |
< |
thisray.rorg[i] += df[0]*ourview.hvec[i] + |
721 |
< |
df[1]*ourview.vvec[i] + |
722 |
< |
dfd*ourview.vdir[i] ; |
723 |
< |
thisray.rdir[i] = vc - thisray.rorg[i]; |
724 |
< |
} |
725 |
< |
} |
726 |
< |
if (normalize(thisray.rdir) == 0.0) |
727 |
< |
return(0.0); |
728 |
< |
} |
696 |
> |
/* depth-of-field */ |
697 |
> |
if (!jitteraperture(thisray.rorg, thisray.rdir, &ourview, dblur)) |
698 |
> |
return(0.0); |
699 |
|
|
700 |
|
rayorigin(&thisray, PRIMARY, NULL, NULL); |
701 |
|
|
702 |
|
rayvalue(&thisray); /* trace ray */ |
703 |
|
|
704 |
< |
copycolor(col, thisray.rcol); /* return color */ |
704 |
> |
if (out_prims == stdprims) { /* return color */ |
705 |
> |
scolor_rgb(col, thisray.rcol); |
706 |
> |
} else if (out_prims == xyzprims) { |
707 |
> |
scolor_cie(col, thisray.rcol); |
708 |
> |
scalecolor(col, WHTEFFICACY); |
709 |
> |
} else if (NCSAMP > 3) { |
710 |
> |
COLOR xyz; |
711 |
> |
if (xyz2myrgbmat[0][0] == 0) |
712 |
> |
compxyz2rgbWBmat(xyz2myrgbmat, out_prims); |
713 |
> |
scolor_cie(xyz, thisray.rcol); |
714 |
> |
colortrans(col, xyz2myrgbmat, xyz); |
715 |
> |
clipgamut(col, xyz[CIEY], CGAMUT_LOWER, cblack, cwhite); |
716 |
> |
} else |
717 |
> |
copycolor(col, thisray.rcol); |
718 |
|
|
719 |
|
return(raydistance(&thisray)); /* return distance */ |
720 |
|
} |