--- ray/src/rt/rtrace.c 1995/08/21 10:29:20 2.19 +++ ray/src/rt/rtrace.c 1997/10/17 10:14:37 2.25 @@ -1,7 +1,7 @@ -/* Copyright (c) 1994 Regents of the University of California */ +/* Copyright (c) 1997 Silicon Graphics, Inc. */ #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static char SCCSid[] = "$SunId$ SGI"; #endif /* @@ -37,6 +37,7 @@ int ndims = 0; /* number of sampling dimensions */ int samplendx = 0; /* index for this sample */ int imm_irrad = 0; /* compute immediate irradiance? */ +int lim_dist = 0; /* limit distance? */ int inform = 'a'; /* input format */ int outform = 'a'; /* output format */ @@ -58,6 +59,11 @@ int vspretest = 512; /* virtual source pretest dens int directvis = 1; /* sources visible? */ double srcsizerat = .2; /* maximum ratio source size/dist. */ +COLOR cextinction = BLKCOLOR; /* global extinction coefficient */ +COLOR salbedo = BLKCOLOR; /* global scattering albedo */ +double seccg = 0.; /* global scattering eccentricity */ +double ssampdist = 0.; /* scatter sampling distance */ + double specthresh = .15; /* specular sampling threshold */ double specjitter = 1.; /* specular sampling jitter */ @@ -67,6 +73,7 @@ int maxdepth = 6; /* maximum recursion depth */ double minweight = 4e-3; /* minimum ray weight */ COLOR ambval = BLKCOLOR; /* ambient value */ +int ambvwt = 0; /* initial weight for ambient value */ double ambacc = 0.2; /* ambient accuracy */ int ambres = 128; /* ambient resolution */ int ambdiv = 512; /* ambient divisions */ @@ -76,7 +83,9 @@ char *amblist[128]; /* ambient include/exclude list int ambincl = -1; /* include == 1, exclude == 0 */ extern OBJREC Lamb; /* a Lambertian surface */ +extern OBJREC Aftplane; /* aft clipping object */ + static RAY thisray; /* for our convenience */ static int oputo(), oputd(), oputv(), oputl(), oputL(), @@ -122,6 +131,7 @@ char *fname; long vcount = hresolu>1 ? hresolu*vresolu : vresolu; long nextflush = hresolu; FILE *fp; + double d; FVECT orig, direc; /* set up input */ if (fname == NULL) @@ -156,20 +166,25 @@ char *fname; while (getvec(orig, inform, fp) == 0 && getvec(direc, inform, fp) == 0) { - if (normalize(direc) == 0.0) { /* zero ==> flush */ - fflush(stdout); - continue; - } - samplendx++; + d = normalize(direc); + if (d == 0.0) { /* zero ==> flush */ + bogusray(); + if (--nextflush <= 0) { + fflush(stdout); + nextflush = hresolu; + } + } else { + samplendx++; /* compute and print */ - if (imm_irrad) - irrad(orig, direc); - else - rad(orig, direc); + if (imm_irrad) + irrad(orig, direc); + else + rad(orig, direc, lim_dist ? d : 0.0); /* flush if time */ - if (--nextflush == 0) { - fflush(stdout); - nextflush = hresolu; + if (--nextflush == 0) { + fflush(stdout); + nextflush = hresolu; + } } if (ferror(stdout)) error(SYSTEM, "write error"); @@ -240,16 +255,31 @@ register char *vs; } -rad(org, dir) /* compute and print ray value(s) */ +bogusray() /* print out empty record */ +{ + thisray.rorg[0] = thisray.rorg[1] = thisray.rorg[2] = + thisray.rdir[0] = thisray.rdir[1] = thisray.rdir[2] = 0.0; + rayorigin(&thisray, NULL, PRIMARY, 1.0); + printvals(&thisray); +} + + +rad(org, dir, dmax) /* compute and print ray value(s) */ FVECT org, dir; +double dmax; { VCOPY(thisray.rorg, org); VCOPY(thisray.rdir, dir); - thisray.rmax = 0.0; + thisray.rmax = dmax; rayorigin(&thisray, NULL, PRIMARY, 1.0); - if (castonly) - localhit(&thisray, &thescene) || sourcehit(&thisray); - else + if (castonly) { + if (!localhit(&thisray, &thescene)) + if (thisray.ro == &Aftplane) { /* clipped */ + thisray.ro = NULL; + thisray.rot = FHUGE; + } else + sourcehit(&thisray); + } else rayvalue(&thisray); printvals(&thisray); } @@ -512,7 +542,10 @@ oputm(r) /* print modifier */ register RAY *r; { if (r->ro != NULL) - fputs(objptr(r->ro->omod)->oname, stdout); + if (r->ro->omod != OVOID) + fputs(objptr(r->ro->omod)->oname, stdout); + else + fputs(VOIDID, stdout); else putchar('*'); putchar('\t');