--- ray/src/rt/rtrace.c 2003/02/25 02:47:23 2.28 +++ ray/src/rt/rtrace.c 2004/03/28 16:31:14 2.36 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: rtrace.c,v 2.28 2003/02/25 02:47:23 greg Exp $"; +static const char RCSid[] = "$Id: rtrace.c,v 2.36 2004/03/28 16:31:14 greg Exp $"; #endif /* * rtrace.c - program and variables for individual ray tracing. @@ -21,10 +21,11 @@ static const char RCSid[] = "$Id: rtrace.c,v 2.28 2003 * irradiance values are desired. */ -#include "ray.h" +#include +#include "platform.h" +#include "ray.h" #include "otypes.h" - #include "resolu.h" CUBE thescene; /* our scene */ @@ -56,8 +57,8 @@ int hresolu = 0; /* horizontal (scan) size */ int vresolu = 0; /* vertical resolution */ double dstrsrc = 0.0; /* square source distribution */ -double shadthresh = .05; /* shadow threshold */ -double shadcert = .5; /* shadow certainty */ +double shadthresh = .03; /* shadow threshold */ +double shadcert = .75; /* shadow certainty */ int directrelay = 2; /* number of source relays */ int vspretest = 512; /* virtual source pretest density */ int directvis = 1; /* sources visible? */ @@ -73,16 +74,16 @@ double specjitter = 1.; /* specular sampling jitter int backvis = 1; /* back face visibility */ -int maxdepth = 6; /* maximum recursion depth */ -double minweight = 4e-3; /* minimum ray weight */ +int maxdepth = 8; /* maximum recursion depth */ +double minweight = 2e-3; /* minimum ray weight */ char *ambfile = NULL; /* ambient file name */ 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 */ -int ambssamp = 0; /* ambient super-samples */ +double ambacc = 0.15; /* ambient accuracy */ +int ambres = 256; /* ambient resolution */ +int ambdiv = 1024; /* ambient divisions */ +int ambssamp = 512; /* ambient super-samples */ int ambounce = 0; /* ambient bounces */ char *amblist[128]; /* ambient include/exclude list */ int ambincl = -1; /* include == 1, exclude == 0 */ @@ -90,7 +91,7 @@ int ambincl = -1; /* include == 1, exclude == 0 */ static RAY thisray; /* for our convenience */ -static void oputo(), oputd(), oputv(), oputl(), oputL(), +static void oputo(), oputd(), oputv(), oputl(), oputL(), oputc(), oputp(), oputn(), oputN(), oputs(), oputw(), oputm(); static void ourtrace(), tabin(); @@ -108,7 +109,7 @@ void quit(code) /* quit program */ int code; { -#ifndef NIX +#ifndef NON_POSIX /* XXX we don't clean up elsewhere? */ headclean(); /* delete header file */ pfclean(); /* clean up persist files */ #endif @@ -146,9 +147,9 @@ char *fname; sprintf(errmsg, "cannot open input file \"%s\"", fname); error(SYSTEM, errmsg); } -#ifdef MSDOS +#ifdef _WIN32 if (inform != 'a') - setmode(fileno(fp), O_BINARY); + SET_FILE_BINARY(fp); #endif /* set up output */ setoutput(outvals); @@ -234,6 +235,9 @@ register char *vs; *table++ = oputl; castonly = 0; break; + case 'c': /* local coordinates */ + *table++ = oputc; + break; case 'L': /* single ray length */ *table++ = oputL; break; @@ -281,12 +285,13 @@ double dmax; thisray.rmax = dmax; rayorigin(&thisray, NULL, PRIMARY, 1.0); if (castonly) { - if (!localhit(&thisray, &thescene)) + if (!localhit(&thisray, &thescene)) { if (thisray.ro == &Aftplane) { /* clipped */ thisray.ro = NULL; thisray.rot = FHUGE; } else sourcehit(&thisray); + } } else rayvalue(&thisray); printvals(&thisray); @@ -429,7 +434,7 @@ RAY *r; static void oputo(r) /* print origin */ -register RAY *r; +RAY *r; { (*putreal)(r->rorg[0]); (*putreal)(r->rorg[1]); @@ -439,7 +444,7 @@ register RAY *r; static void oputd(r) /* print direction */ -register RAY *r; +RAY *r; { (*putreal)(r->rdir[0]); (*putreal)(r->rdir[1]); @@ -449,7 +454,7 @@ register RAY *r; static void oputv(r) /* print value */ -register RAY *r; +RAY *r; { COLR cout; @@ -468,7 +473,7 @@ register RAY *r; static void oputl(r) /* print effective distance */ -register RAY *r; +RAY *r; { (*putreal)(r->rt); } @@ -476,15 +481,24 @@ register RAY *r; static void oputL(r) /* print single ray length */ -register RAY *r; +RAY *r; { (*putreal)(r->rot); } static void +oputc(r) /* print local coordinates */ +RAY *r; +{ + (*putreal)(r->uv[0]); + (*putreal)(r->uv[1]); +} + + +static void oputp(r) /* print point */ -register RAY *r; +RAY *r; { if (r->rot < FHUGE) { (*putreal)(r->rop[0]); @@ -500,7 +514,7 @@ register RAY *r; static void oputN(r) /* print unperturbed normal */ -register RAY *r; +RAY *r; { if (r->rot < FHUGE) { (*putreal)(r->ron[0]); @@ -535,7 +549,7 @@ RAY *r; static void oputs(r) /* print name */ -register RAY *r; +RAY *r; { if (r->ro != NULL) fputs(r->ro->oname, stdout); @@ -547,7 +561,7 @@ register RAY *r; static void oputw(r) /* print weight */ -register RAY *r; +RAY *r; { (*putreal)(r->rweight); } @@ -555,7 +569,7 @@ register RAY *r; static void oputm(r) /* print modifier */ -register RAY *r; +RAY *r; { if (r->ro != NULL) if (r->ro->omod != OVOID)