--- ray/src/rt/mkpmap.c 2016/05/17 17:39:47 2.5 +++ ray/src/rt/mkpmap.c 2018/02/02 19:47:55 2.8 @@ -1,7 +1,8 @@ #ifndef lint -static const char RCSid[] = "$Id: mkpmap.c,v 2.5 2016/05/17 17:39:47 rschregle Exp $"; +static const char RCSid[] = "$Id: mkpmap.c,v 2.8 2018/02/02 19:47:55 rschregle Exp $"; #endif + /* ====================================================================== Photon map generator @@ -13,11 +14,10 @@ static const char RCSid[] = "$Id: mkpmap.c,v 2.5 2016/ supported by the Swiss National Science Foundation (SNSF, #147053) ====================================================================== - $Id: mkpmap.c,v 2.5 2016/05/17 17:39:47 rschregle Exp $ + $Id: mkpmap.c,v 2.8 2018/02/02 19:47:55 rschregle Exp $ */ - #include "pmap.h" #include "pmapmat.h" #include "pmapcontrib.h" @@ -30,11 +30,13 @@ static const char RCSid[] = "$Id: mkpmap.c,v 2.5 2016/ #include +/* Enable options for Ze Ekspertz only! */ +#define PMAP_EKSPERTZ + extern char VersionID []; - char* progname; /* argv[0] */ int dimlist [MAXDIM]; /* sampling dimensions */ int ndims = 0; /* number of sampling dimenshunns */ @@ -57,7 +59,6 @@ unsigned nproc = 1; /* number of paral #endif - /* Dummies for linkage */ COLOR ambval = BLKCOLOR; @@ -70,69 +71,65 @@ int ambvwt = 0, ambssamp = 0, ambres = 32, ambounce = char *shm_boundary = NULL, *ambfile = NULL, *RCCONTEXT = NULL; void (*trace)() = NULL, (*addobjnotify [])() = {ambnotify, NULL}; - void printdefaults() /* print default values to stdout */ { - puts("-apg file nPhotons\t\t# global photon map"); - puts("-apc file nPhotons\t\t# caustic photon map"); - puts("-apd file nPhotons\t\t# direct photon map"); - puts("-app file nPhotons bwidth\t# precomputed global photon map"); -#if 0 - /* Hide this option as most likely useless and confusing to user */ - puts("-appb file nPhotons minBw maxBw\t# precomp bias comp global pmap"); + +#ifdef EVALDRC_HACK + /* EvalDRC support */ + puts("-A\t\t\t\t# angular source file"); +#endif +#ifdef PMAP_EKSPERTZ + puts("-api xmin ymin zmin xmax ymax zmax\t# region of interest"); #endif - puts("-apv file nPhotons\t\t# volume photon map"); - puts("-apC file nPhotons\t\t# contribution photon map"); - - printf("-apD %f\t\t\t# predistribution factor\n", preDistrib); - printf("-apM %d\t\t\t\t# max predistrib passes\n", maxPreDistrib); - printf("-apm %ld\t\t\t# max photon bounces\n", photonMaxBounce); - puts("-apo mod\t\t\t# photon port modifier"); - puts("-apO file\t\t\t# photon port file"); - printf("-apP %f\t\t\t# precomputation factor\n", finalGather); - printf("-apr %d\t\t\t\t# random seed\n", randSeed); - puts("-aps mod\t\t\t# antimatter sensor modifier"); - puts("-apS file\t\t\t# antimatter sensor file"); + puts("-apg file nPhotons\t\t\t# global photon map"); + puts("-apc file nPhotons\t\t\t# caustic photon map"); + puts("-apd file nPhotons\t\t\t# direct photon map"); + puts("-app file nPhotons bwidth\t\t# precomputed global photon map"); + puts("-apv file nPhotons\t\t\t# volume photon map"); + puts("-apC file nPhotons\t\t\t# contribution photon map"); + printf("-apD %f\t\t\t\t# predistribution factor\n", preDistrib); + printf("-apM %d\t\t\t\t\t# max predistrib passes\n", maxPreDistrib); +#if 1 + /* Kept for backwards compat, will be gradually phased out by -lD, -lr */ + printf("-apm %ld\t\t\t\t# limit photon bounces\n", photonMaxBounce); +#endif + puts("-apo mod\t\t\t\t# photon port modifier"); + puts("-apO file\t\t\t\t# photon port file"); + printf("-apP %f\t\t\t\t# precomputation factor\n", finalGather); + printf("-apr %d\t\t\t\t\t# random seed\n", randSeed); + puts("-aps mod\t\t\t\t# antimatter sensor modifier"); + puts("-apS file\t\t\t\t# antimatter sensor file"); - printf(backvis ? "-bv+\t\t\t\t# back face visibility on\n" - : "-bv-\t\t\t\t# back face visibility off\n"); - printf("-dp %.1f\t\t\t# PDF samples / sr\n", pdfSamples); - printf("-ds %f\t\t\t# source partition size ratio\n", srcsizerat); - printf("-e %s\t\t\t# diagnostics output file\n", diagFile); - printf(clobber ? "-fo+\t\t\t\t# force overwrite" - : "-fo-\t\t\t\t# do not overwrite\n"); -#if 0 - /* Heap size increment now fixed & defined by macro in pmapkdt.c */ - printf("-i %-9ld\t\t\t# photon heap size increment\n", - photonHeapSizeInc); -#endif - printf("-ma %.2f %.2f %.2f\t\t# scattering albedo\n", + printf(backvis ? "-bv+\t\t\t\t\t# back face visibility on\n" + : "-bv-\t\t\t\t\t# back face visibility off\n"); + printf("-dp %.1f\t\t\t\t# PDF samples / sr\n", pdfSamples); + printf("-ds %f\t\t\t\t# source partition size ratio\n", srcsizerat); + printf("-e %s\t\t\t\t# diagnostics output file\n", diagFile); + printf(clobber ? "-fo+\t\t\t\t\t# force overwrite\n" + : "-fo-\t\t\t\t\t# do not overwrite\n"); +#ifdef PMAP_EKSPERTZ + /* NU STUFF for Ze Exspertz! */ + printf("-ld %.1f\t\t\t\t\t# limit photon distance\n", photonMaxDist); + printf("-lr %ld\t\t\t\t# limit photon bounces\n", photonMaxBounce); +#endif + printf("-ma %.2f %.2f %.2f\t\t\t# scattering albedo\n", colval(salbedo,RED), colval(salbedo,GRN), colval(salbedo,BLU)); - printf("-me %.2e %.2e %.2e\t# extinction coefficient\n", + printf("-me %.2e %.2e %.2e\t\t# extinction coefficient\n", colval(cextinction,RED), colval(cextinction,GRN), colval(cextinction,BLU)); - printf("-mg %.2f\t\t\t# scattering eccentricity\n", seccg); - printf("-n %d\t\t\t\t# number of parallel processes\n", nproc); - printf("-t %-9d\t\t\t# time between reports\n", photonRepTime); - -#ifdef PMAP_ROI - /* Ziss option for ze egg-spurtz only! */ - printf("-api \t%.0e %.0e %.0e\n\t%.0e %.0e %.0e\t# region of interest\n", - pmapROI [0], pmapROI [1], pmapROI [2], pmapROI [3], - pmapROI [4], pmapROI [5]); + printf("-mg %.2f\t\t\t\t# scattering eccentricity\n", seccg); +#if NIX + /* Multiprocessing on NIX only */ + printf("-n %d\t\t\t\t\t# number of parallel processes\n", nproc); #endif - -#ifdef EVALDRC_HACK - /* ... and ziss one... */ - puts("-A\t\t\t\t# angular source file"); -#endif + printf("-t %-9d\t\t\t\t# time between reports\n", photonRepTime); + printf(verbose ? "-v+\t\t\t\t\t# verbose console output\n" + : "-v-\t\t\t\t\t# terse console output\n"); } - - int main (int argc, char* argv []) { #define check(ol, al) if (argv [i][ol] || \ @@ -196,15 +193,7 @@ int main (int argc, char* argv []) if (!globalPmapParams.distribTarget) goto badopt; globalPmapParams.minGather = globalPmapParams.maxGather = 0; - } - - else if (!strcmp(argv [i] + 2, "pm")) { - /* Max photon bounces */ - check(4, "i"); - photonMaxBounce = atol(argv [++i]); - if (!photonMaxBounce) - goto badopt; - } + } else if (!strcmp(argv [i] + 2, "pp")) { /* Precomputed global photon map */ @@ -220,24 +209,6 @@ int main (int argc, char* argv []) goto badopt; } -#if 0 - else if (!strcmp(argv [i] + 2, "ppb")) { - /* Precomputed global photon map + bias comp. */ - check(5, "ssii"); - preCompPmapParams.fileName = argv [++i]; - preCompPmapParams.distribTarget = - parseMultiplier(argv [++i]); - if (!preCompPmapParams.distribTarget) - goto badopt; - preCompPmapParams.minGather = atoi(argv [++i]); - preCompPmapParams.maxGather = atoi(argv [++i]); - if (!preCompPmapParams.minGather || - preCompPmapParams.minGather >= - preCompPmapParams.maxGather) - goto badopt; - } -#endif - else if (!strcmp(argv [i] + 2, "pc")) { /* Caustic photon map */ check(4, "ss"); @@ -277,25 +248,56 @@ int main (int argc, char* argv []) if (!contribPmapParams.distribTarget) goto badopt; } - + else if (!strcmp(argv [i] + 2, "pD")) { /* Predistribution factor */ check(4, "f"); preDistrib = atof(argv [++i]); if (preDistrib <= 0) error(USER, "predistribution factor must be > 0"); - } + } -#ifdef PMAP_ROI - /* Region of interest; ziss option for ze egg-spurtz only! */ + else if (!strcmp(argv [i] + 2, "pM")) { + /* Max predistribution passes */ + check(4, "i"); + maxPreDistrib = atoi(argv [++i]); + if (maxPreDistrib <= 0) + error(USER, "max predistribution passes must be > 0"); + } +#if 1 + /* Kept for backwards compat, to be phased out by -lr */ + else if (!strcmp(argv [i] + 2, "pm")) { + /* Max photon bounces */ + check(4, "i"); + photonMaxBounce = atol(argv [++i]); + if (photonMaxBounce <= 0) + error(USER, "max photon bounces must be > 0"); + } +#endif +#ifdef PMAP_EKSPERTZ + /* Add region of interest; for Ze Ekspertz only! */ else if (!strcmp(argv [i] + 2, "pi")) { - int j; + unsigned j, n = pmapNumROI; check(4, "ffffff"); - for (j = 0; j < 6; j++) - pmapROI [j] = atof(argv [++i]); - } -#endif - + + pmapROI = realloc(pmapROI, + ++pmapNumROI * sizeof(PhotonMapROI)); + if (!pmapROI) + error(SYSTEM, "failed to allocate ROI"); + + pmapROI [n].min [0] = atof(argv [++i]); + pmapROI [n].min [1] = atof(argv [++i]); + pmapROI [n].min [2] = atof(argv [++i]); + pmapROI [n].max [0] = atof(argv [++i]); + pmapROI [n].max [1] = atof(argv [++i]); + pmapROI [n].max [2] = atof(argv [++i]); + + for (j = 0; j < 3; j++) + if (pmapROI [n].min [j] >= pmapROI [n].max [j]) + error(USER, + "invalid region of interest (swapped min/max?)"); + } +#endif else if (!strcmp(argv [i] + 2, "pP")) { /* Global photon precomputation factor */ check(4, "f"); @@ -316,7 +318,7 @@ int main (int argc, char* argv []) } if (argv[i][3] == 'O') { - /* Get port modifiers file */ + /* Get port modifiers from file */ rval = wordfile(portLp, AMBLLEN-(portLp-amblist), getpath(argv [++i], getrlibpath(), R_OK)); @@ -409,15 +411,27 @@ int main (int argc, char* argv []) else goto badopt; break; - -#if 0 - /* Heap size increment now fixed & defined by macro in pmapkdt.c */ - case 'i': /* Photon heap size increment */ - check(2, "i"); - photonHeapSizeInc = atol(argv [++i]); +#ifdef PMAP_EKSPERTZ + case 'l': /* Limits */ + switch (argv [i][2]) { + case 'd': /* Limit photon path distance */ + check(3, "f"); + photonMaxDist = atof(argv [++i]); + if (photonMaxDist <= 0) + error(USER, "max photon distance must be > 0"); + break; + + case 'r': /* Limit photon bounces */ + check(3, "i"); + photonMaxBounce = atol(argv [++i]); + if (photonMaxBounce <= 0) + error(USER, "max photon bounces must be > 0"); + break; + + default: goto badopt; + } break; -#endif - +#endif case 'm': /* Medium */ switch (argv[i][2]) { case 'e': /* Eggs-tinction coefficient */ @@ -442,8 +456,8 @@ int main (int argc, char* argv []) default: goto badopt; } break; - - case 'n': /* Num parallel processes */ +#if NIX + case 'n': /* Num parallel processes (NIX only) */ check(2, "i"); nproc = atoi(argv [++i]); @@ -452,22 +466,23 @@ int main (int argc, char* argv []) sprintf(errmsg, "too many parallel processes, clamping to " "%d\n", nproc); error(WARNING, errmsg); - } - + } break; - +#endif case 't': /* Timer */ check(2, "i"); photonRepTime = atoi(argv [++i]); break; - + + case 'v': /* Verbosity */ + check_bool(2, verbose); + break; #ifdef EVALDRC_HACK case 'A': /* Angular source file */ check(2,"s"); angsrcfile = argv[++i]; break; -#endif - +#endif default: goto badopt; } } @@ -507,12 +522,10 @@ int main (int argc, char* argv []) error(USER, "no photon maps specified"); readoct(octname, loadflags, &thescene, NULL); - #ifdef EVALDRC_HACK if (angsrcfile) readobj(angsrcfile); /* load angular sources */ -#endif - +#endif nsceneobjs = nobjects; /* Get sources */