1 |
< |
/* Copyright (c) 1995 Regents of the University of California */ |
1 |
> |
/* Copyright (c) 1996 Regents of the University of California */ |
2 |
|
|
3 |
|
#ifndef lint |
4 |
|
static char SCCSid[] = "$SunId$ LBL"; |
53 |
|
double maxdiff = .05; /* max. difference for interpolation */ |
54 |
|
double dstrpix = 0.67; /* square pixel distribution */ |
55 |
|
|
56 |
+ |
double mblur = 0.; /* motion blur parameter */ |
57 |
+ |
|
58 |
|
double dstrsrc = 0.0; /* square source distribution */ |
59 |
|
double shadthresh = .05; /* shadow threshold */ |
60 |
|
double shadcert = .5; /* shadow certainty */ |
104 |
|
|
105 |
|
#define pixjitter() (.5+dstrpix*(.5-frandom())) |
106 |
|
|
107 |
< |
static int hres, vres; /* resolution for this frame */ |
107 |
> |
int hres, vres; /* resolution for this frame */ |
108 |
|
|
109 |
+ |
static VIEW lastview; /* the previous view input */ |
110 |
+ |
|
111 |
|
extern char *mktemp(); |
112 |
|
|
113 |
|
double pixvalue(); |
335 |
|
{ |
336 |
|
char linebuf[256]; |
337 |
|
|
338 |
+ |
copystruct(&lastview, &ourview); |
339 |
|
while (fgets(linebuf, sizeof(linebuf), fp) != NULL) |
340 |
|
if (isview(linebuf) && sscanview(&ourview, linebuf) > 0) |
341 |
|
return(0); |
408 |
|
else |
409 |
|
#endif |
410 |
|
signal(SIGCONT, report); |
411 |
< |
ypos = vres-1 - i; |
411 |
> |
ypos = vres-1 - i; /* initialize sampling */ |
412 |
> |
if (directvis) |
413 |
> |
init_drawsources(psample); |
414 |
|
fillscanline(scanbar[0], zbar[0], sampdens, hres, ypos, hstep); |
415 |
|
/* compute scanlines */ |
416 |
|
for (ypos -= ystep; ypos > -ystep; ypos -= ystep) { |
430 |
|
hres, ypos, hstep); |
431 |
|
/* fill bar */ |
432 |
|
fillscanbar(scanbar, zbar, hres, ypos, ystep); |
433 |
< |
/* add bitty sources */ |
434 |
< |
drawsources(&ourview, hres, vres, scanbar, zbar, |
428 |
< |
0, hres, ypos, ystep, psample); |
433 |
> |
if (directvis) /* add bitty sources */ |
434 |
> |
drawsources(scanbar, zbar, 0, hres, ypos, ystep); |
435 |
|
/* write it out */ |
436 |
|
#ifndef BSD |
437 |
|
signal(SIGCONT, SIG_IGN); /* don't interrupt writes */ |
608 |
|
COLOR col; /* returned color */ |
609 |
|
int x, y; /* pixel position */ |
610 |
|
{ |
611 |
< |
static RAY thisray; |
612 |
< |
|
613 |
< |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview, |
614 |
< |
(x+pixjitter())/hres, (y+pixjitter())/vres)) < -FTINY) { |
611 |
> |
RAY thisray; |
612 |
> |
FVECT lorg, ldir; |
613 |
> |
double hpos, vpos, lmax, d; |
614 |
> |
/* compute view ray */ |
615 |
> |
hpos = (x+pixjitter())/hres; |
616 |
> |
vpos = (y+pixjitter())/vres; |
617 |
> |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
618 |
> |
&ourview, hpos, vpos)) < -FTINY) { |
619 |
|
setcolor(col, 0.0, 0.0, 0.0); |
620 |
|
return(0.0); |
621 |
|
} |
622 |
|
|
613 |
– |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
614 |
– |
|
623 |
|
samplendx = pixnumber(x,y,hres,vres); /* set pixel index */ |
624 |
+ |
|
625 |
+ |
/* optional motion blur */ |
626 |
+ |
if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir, |
627 |
+ |
&lastview, hpos, vpos)) >= -FTINY) { |
628 |
+ |
register int i; |
629 |
+ |
register double d = mblur*(.5-urand(281+samplendx)); |
630 |
+ |
|
631 |
+ |
thisray.rmax = (1.-d)*thisray.rmax + d*lmax; |
632 |
+ |
for (i = 3; i--; ) { |
633 |
+ |
thisray.rorg[i] = (1.-d)*thisray.rorg[i] + d*lorg[i]; |
634 |
+ |
thisray.rdir[i] = (1.-d)*thisray.rdir[i] + d*ldir[i]; |
635 |
+ |
} |
636 |
+ |
if (normalize(thisray.rdir) == 0.0) |
637 |
+ |
return(0.0); |
638 |
+ |
} |
639 |
+ |
|
640 |
+ |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
641 |
|
|
642 |
|
rayvalue(&thisray); /* trace ray */ |
643 |
|
|