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(); |
232 |
|
for ( ; seq < rn; seq++) |
233 |
|
if (nextview(stdin) == EOF) |
234 |
|
error(USER, "unexpected EOF on view input"); |
235 |
+ |
setview(&ourview); |
236 |
|
prvr = fbuf; /* mark for renaming */ |
237 |
|
} |
238 |
|
if (pout != NULL & prvr != NULL) { |
274 |
|
fbuf); |
275 |
|
error(USER, errmsg); |
276 |
|
} |
277 |
+ |
setview(&ourview); |
278 |
|
continue; /* don't clobber */ |
279 |
|
} |
280 |
|
if (freopen(fbuf, "w", stdout) == NULL) { |
337 |
|
{ |
338 |
|
char linebuf[256]; |
339 |
|
|
340 |
+ |
copystruct(&lastview, &ourview); |
341 |
|
while (fgets(linebuf, sizeof(linebuf), fp) != NULL) |
342 |
|
if (isview(linebuf) && sscanview(&ourview, linebuf) > 0) |
343 |
|
return(0); |
348 |
|
render(zfile, oldfile) /* render the scene */ |
349 |
|
char *zfile, *oldfile; |
350 |
|
{ |
344 |
– |
extern long lseek(); |
351 |
|
COLOR *scanbar[MAXDIV+1]; /* scanline arrays of pixel values */ |
352 |
|
float *zbar[MAXDIV+1]; /* z values */ |
353 |
|
char *sampdens; /* previous sample density */ |
400 |
|
if (i >= vres) |
401 |
|
goto alldone; |
402 |
|
if (zfd != -1 && i > 0 && |
403 |
< |
lseek(zfd, (long)i*hres*sizeof(float), 0) == -1) |
403 |
> |
lseek(zfd, (long)i*hres*sizeof(float), 0) < 0) |
404 |
|
error(SYSTEM, "z-file seek error in render"); |
405 |
|
pctdone = 100.0*i/vres; |
406 |
|
if (ralrm > 0) /* report init stats */ |
409 |
|
else |
410 |
|
#endif |
411 |
|
signal(SIGCONT, report); |
412 |
< |
ypos = vres-1 - i; |
412 |
> |
ypos = vres-1 - i; /* initialize sampling */ |
413 |
> |
if (directvis) |
414 |
> |
init_drawsources(psample); |
415 |
|
fillscanline(scanbar[0], zbar[0], sampdens, hres, ypos, hstep); |
416 |
|
/* compute scanlines */ |
417 |
|
for (ypos -= ystep; ypos > -ystep; ypos -= ystep) { |
431 |
|
hres, ypos, hstep); |
432 |
|
/* fill bar */ |
433 |
|
fillscanbar(scanbar, zbar, hres, ypos, ystep); |
434 |
< |
/* add bitty sources */ |
435 |
< |
drawsources(&ourview, hres, vres, scanbar, zbar, |
428 |
< |
0, hres, ypos, ystep, psample); |
434 |
> |
if (directvis) /* add bitty sources */ |
435 |
> |
drawsources(scanbar, zbar, 0, hres, ypos, ystep); |
436 |
|
/* write it out */ |
437 |
|
#ifndef BSD |
438 |
|
signal(SIGCONT, SIG_IGN); /* don't interrupt writes */ |
609 |
|
COLOR col; /* returned color */ |
610 |
|
int x, y; /* pixel position */ |
611 |
|
{ |
612 |
< |
static RAY thisray; |
613 |
< |
|
614 |
< |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, &ourview, |
615 |
< |
(x+pixjitter())/hres, (y+pixjitter())/vres)) < -FTINY) { |
612 |
> |
RAY thisray; |
613 |
> |
FVECT lorg, ldir; |
614 |
> |
double hpos, vpos, lmax, d; |
615 |
> |
/* compute view ray */ |
616 |
> |
hpos = (x+pixjitter())/hres; |
617 |
> |
vpos = (y+pixjitter())/vres; |
618 |
> |
if ((thisray.rmax = viewray(thisray.rorg, thisray.rdir, |
619 |
> |
&ourview, hpos, vpos)) < -FTINY) { |
620 |
|
setcolor(col, 0.0, 0.0, 0.0); |
621 |
|
return(0.0); |
622 |
|
} |
623 |
|
|
613 |
– |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
614 |
– |
|
624 |
|
samplendx = pixnumber(x,y,hres,vres); /* set pixel index */ |
625 |
+ |
|
626 |
+ |
/* optional motion blur */ |
627 |
+ |
if (lastview.type && mblur > FTINY && (lmax = viewray(lorg, ldir, |
628 |
+ |
&lastview, hpos, vpos)) >= -FTINY) { |
629 |
+ |
register int i; |
630 |
+ |
register double d = mblur*(.5-urand(281+samplendx)); |
631 |
+ |
|
632 |
+ |
thisray.rmax = (1.-d)*thisray.rmax + d*lmax; |
633 |
+ |
for (i = 3; i--; ) { |
634 |
+ |
thisray.rorg[i] = (1.-d)*thisray.rorg[i] + d*lorg[i]; |
635 |
+ |
thisray.rdir[i] = (1.-d)*thisray.rdir[i] + d*ldir[i]; |
636 |
+ |
} |
637 |
+ |
if (normalize(thisray.rdir) == 0.0) |
638 |
+ |
return(0.0); |
639 |
+ |
} |
640 |
+ |
|
641 |
+ |
rayorigin(&thisray, NULL, PRIMARY, 1.0); |
642 |
|
|
643 |
|
rayvalue(&thisray); /* trace ray */ |
644 |
|
|