ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/mkpmap.c
(Generate patch)

Comparing ray/src/rt/mkpmap.c (file contents):
Revision 2.5 by rschregle, Tue May 17 17:39:47 2016 UTC vs.
Revision 2.8 by rschregle, Fri Feb 2 19:47:55 2018 UTC

# Line 2 | Line 2
2   static const char RCSid[] = "$Id$";
3   #endif
4  
5 +
6   /*
7     ======================================================================
8     Photon map generator
# Line 17 | Line 18 | static const char RCSid[] = "$Id$";
18   */
19  
20  
20
21   #include "pmap.h"
22   #include "pmapmat.h"
23   #include "pmapcontrib.h"
# Line 30 | Line 30 | static const char RCSid[] = "$Id$";
30   #include <sys/stat.h>
31  
32  
33 + /* Enable options for Ze Ekspertz only! */
34 + #define PMAP_EKSPERTZ
35  
36 +
37   extern char VersionID [];
38  
39  
37
40   char*    progname;                  /* argv[0] */
41   int      dimlist [MAXDIM];          /* sampling dimensions */
42   int      ndims = 0;                 /* number of sampling dimenshunns */
# Line 57 | Line 59 | unsigned nproc = 1;                 /* number of paral
59   #endif
60  
61  
60
62   /* Dummies for linkage */
63  
64   COLOR ambval = BLKCOLOR;
# Line 70 | Line 71 | int ambvwt = 0, ambssamp = 0, ambres = 32, ambounce =
71   char *shm_boundary = NULL, *ambfile = NULL, *RCCONTEXT = NULL;
72   void (*trace)() = NULL, (*addobjnotify [])() = {ambnotify, NULL};
73  
73
74    
75   void printdefaults()
76   /* print default values to stdout */
77   {
78 <   puts("-apg file nPhotons\t\t# global photon map");
79 <   puts("-apc file nPhotons\t\t# caustic photon map");          
80 <   puts("-apd file nPhotons\t\t# direct photon map");
81 <   puts("-app file nPhotons bwidth\t# precomputed global photon map");
82 < #if 0
83 <   /* Hide this option as most likely useless and confusing to user */
84 <   puts("-appb file nPhotons minBw maxBw\t# precomp bias comp global pmap");
78 >
79 > #ifdef EVALDRC_HACK
80 >   /* EvalDRC support */
81 >   puts("-A\t\t\t\t# angular source file");
82 > #endif    
83 > #ifdef PMAP_EKSPERTZ
84 >   puts("-api xmin ymin zmin xmax ymax zmax\t# region of interest");
85   #endif
86 <   puts("-apv file nPhotons\t\t# volume photon map");
87 <   puts("-apC file nPhotons\t\t# contribution photon map");
88 <  
89 <   printf("-apD %f\t\t\t# predistribution factor\n", preDistrib);
90 <   printf("-apM %d\t\t\t\t# max predistrib passes\n", maxPreDistrib);
91 <   printf("-apm %ld\t\t\t# max photon bounces\n", photonMaxBounce);                            
92 <   puts("-apo mod\t\t\t# photon port modifier");
93 <   puts("-apO file\t\t\t# photon port file");
94 <   printf("-apP %f\t\t\t# precomputation factor\n", finalGather);
95 <   printf("-apr %d\t\t\t\t# random seed\n", randSeed);
96 <   puts("-aps mod\t\t\t# antimatter sensor modifier");
97 <   puts("-apS file\t\t\t# antimatter sensor file");
86 >   puts("-apg file nPhotons\t\t\t# global photon map");
87 >   puts("-apc file nPhotons\t\t\t# caustic photon map");          
88 >   puts("-apd file nPhotons\t\t\t# direct photon map");
89 >   puts("-app file nPhotons bwidth\t\t# precomputed global photon map");
90 >   puts("-apv file nPhotons\t\t\t# volume photon map");
91 >   puts("-apC file nPhotons\t\t\t# contribution photon map");  
92 >   printf("-apD %f\t\t\t\t# predistribution factor\n", preDistrib);
93 >   printf("-apM %d\t\t\t\t\t# max predistrib passes\n", maxPreDistrib);
94 > #if 1
95 >   /* Kept for backwards compat, will be gradually phased out by -lD, -lr */
96 >   printf("-apm %ld\t\t\t\t# limit photon bounces\n", photonMaxBounce);
97 > #endif
98 >   puts("-apo mod\t\t\t\t# photon port modifier");
99 >   puts("-apO file\t\t\t\t# photon port file");
100 >   printf("-apP %f\t\t\t\t# precomputation factor\n", finalGather);
101 >   printf("-apr %d\t\t\t\t\t# random seed\n", randSeed);
102 >   puts("-aps mod\t\t\t\t# antimatter sensor modifier");
103 >   puts("-apS file\t\t\t\t# antimatter sensor file");
104  
105 <   printf(backvis ? "-bv+\t\t\t\t# back face visibility on\n"
106 <                  : "-bv-\t\t\t\t# back face visibility off\n");
107 <   printf("-dp  %.1f\t\t\t# PDF samples / sr\n", pdfSamples);
108 <   printf("-ds  %f\t\t\t# source partition size ratio\n", srcsizerat);
109 <   printf("-e   %s\t\t\t# diagnostics output file\n", diagFile);
110 <   printf(clobber ? "-fo+\t\t\t\t# force overwrite"
111 <                  : "-fo-\t\t\t\t# do not overwrite\n");
112 < #if 0
113 <   /* Heap size increment now fixed & defined by macro in pmapkdt.c */
114 <   printf("-i   %-9ld\t\t\t# photon heap size increment\n",
115 <          photonHeapSizeInc);
116 < #endif          
117 <   printf("-ma  %.2f %.2f %.2f\t\t# scattering albedo\n",
105 >   printf(backvis ? "-bv+\t\t\t\t\t# back face visibility on\n"
106 >                  : "-bv-\t\t\t\t\t# back face visibility off\n");
107 >   printf("-dp  %.1f\t\t\t\t# PDF samples / sr\n", pdfSamples);
108 >   printf("-ds  %f\t\t\t\t# source partition size ratio\n", srcsizerat);
109 >   printf("-e   %s\t\t\t\t# diagnostics output file\n", diagFile);
110 >   printf(clobber ? "-fo+\t\t\t\t\t# force overwrite\n"
111 >                  : "-fo-\t\t\t\t\t# do not overwrite\n");
112 > #ifdef PMAP_EKSPERTZ
113 >   /* NU STUFF for Ze Exspertz! */      
114 >   printf("-ld %.1f\t\t\t\t\t# limit photon distance\n", photonMaxDist);
115 >   printf("-lr %ld\t\t\t\t# limit photon bounces\n", photonMaxBounce);  
116 > #endif  
117 >   printf("-ma  %.2f %.2f %.2f\t\t\t# scattering albedo\n",
118            colval(salbedo,RED), colval(salbedo,GRN), colval(salbedo,BLU));
119 <   printf("-me  %.2e %.2e %.2e\t# extinction coefficient\n",
119 >   printf("-me  %.2e %.2e %.2e\t\t# extinction coefficient\n",
120            colval(cextinction,RED), colval(cextinction,GRN),
121            colval(cextinction,BLU));          
122 <   printf("-mg  %.2f\t\t\t# scattering eccentricity\n", seccg);
123 <   printf("-n   %d\t\t\t\t# number of parallel processes\n", nproc);
124 <   printf("-t   %-9d\t\t\t# time between reports\n", photonRepTime);
125 <
120 < #ifdef PMAP_ROI
121 <   /* Ziss option for ze egg-spurtz only! */
122 <   printf("-api \t%.0e %.0e %.0e\n\t%.0e %.0e %.0e\t# region of interest\n",
123 <          pmapROI [0], pmapROI [1], pmapROI [2], pmapROI [3],
124 <          pmapROI [4], pmapROI [5]);
122 >   printf("-mg  %.2f\t\t\t\t# scattering eccentricity\n", seccg);
123 > #if NIX  
124 >   /* Multiprocessing on NIX only */
125 >   printf("-n   %d\t\t\t\t\t# number of parallel processes\n", nproc);
126   #endif  
127 <
128 < #ifdef EVALDRC_HACK
129 <   /* ... and ziss one... */
129 <   puts("-A\t\t\t\t# angular source file");
130 < #endif
127 >   printf("-t   %-9d\t\t\t\t# time between reports\n", photonRepTime);
128 >   printf(verbose ? "-v+\t\t\t\t\t# verbose console output\n"
129 >                  : "-v-\t\t\t\t\t# terse console output\n");
130   }
131  
132  
134
135
133   int main (int argc, char* argv [])
134   {
135     #define check(ol, al) if (argv [i][ol] || \
# Line 196 | Line 193 | int main (int argc, char* argv [])
193                 if (!globalPmapParams.distribTarget)
194                    goto badopt;                        
195                 globalPmapParams.minGather = globalPmapParams.maxGather = 0;
196 <            }
200 <                              
201 <            else if (!strcmp(argv [i] + 2, "pm")) {
202 <               /* Max photon bounces */
203 <               check(4, "i");
204 <               photonMaxBounce = atol(argv [++i]);
205 <               if (!photonMaxBounce)
206 <                  goto badopt;
207 <            }
196 >            }                              
197              
198              else if (!strcmp(argv [i] + 2, "pp")) {
199                 /* Precomputed global photon map */
# Line 220 | Line 209 | int main (int argc, char* argv [])
209                    goto badopt;
210              }
211              
223 #if 0
224            else if (!strcmp(argv [i] + 2, "ppb")) {
225               /* Precomputed global photon map + bias comp. */
226               check(5, "ssii");
227               preCompPmapParams.fileName = argv [++i];
228               preCompPmapParams.distribTarget =
229                  parseMultiplier(argv [++i]);
230               if (!preCompPmapParams.distribTarget)
231                  goto badopt;                      
232               preCompPmapParams.minGather = atoi(argv [++i]);
233               preCompPmapParams.maxGather = atoi(argv [++i]);
234               if (!preCompPmapParams.minGather ||
235                   preCompPmapParams.minGather >=
236                   preCompPmapParams.maxGather)
237                  goto badopt;
238            }
239 #endif
240            
212              else if (!strcmp(argv [i] + 2, "pc")) {
213                 /* Caustic photon map */
214                 check(4, "ss");
# Line 277 | Line 248 | int main (int argc, char* argv [])
248                 if (!contribPmapParams.distribTarget)
249                    goto badopt;
250              }
251 <            
251 >
252              else if (!strcmp(argv [i] + 2, "pD")) {
253                 /* Predistribution factor */
254                 check(4, "f");
255                 preDistrib = atof(argv [++i]);
256                 if (preDistrib <= 0)
257                    error(USER, "predistribution factor must be > 0");
258 <            }  
258 >            }
259  
260 < #ifdef PMAP_ROI
261 <            /* Region of interest; ziss option for ze egg-spurtz only! */
260 >            else if (!strcmp(argv [i] + 2, "pM")) {
261 >               /* Max predistribution passes */
262 >               check(4, "i");
263 >               maxPreDistrib = atoi(argv [++i]);
264 >               if (maxPreDistrib <= 0)
265 >                  error(USER, "max predistribution passes must be > 0");
266 >            }
267 > #if 1
268 >            /* Kept for backwards compat, to be phased out by -lr */
269 >            else if (!strcmp(argv [i] + 2, "pm")) {
270 >               /* Max photon bounces */
271 >               check(4, "i");              
272 >               photonMaxBounce = atol(argv [++i]);
273 >               if (photonMaxBounce <= 0)
274 >                  error(USER, "max photon bounces must be > 0");
275 >            }            
276 > #endif
277 > #ifdef PMAP_EKSPERTZ
278 >            /* Add region of interest; for Ze Ekspertz only! */
279              else if (!strcmp(argv [i] + 2, "pi")) {
280 <               int j;
280 >               unsigned j, n = pmapNumROI;
281                 check(4, "ffffff");
282 <               for (j = 0; j < 6; j++)
283 <                  pmapROI [j] = atof(argv [++i]);
284 <            }              
285 < #endif
286 <            
282 >              
283 >               pmapROI = realloc(pmapROI,
284 >                                 ++pmapNumROI * sizeof(PhotonMapROI));
285 >               if (!pmapROI)
286 >                  error(SYSTEM, "failed to allocate ROI");
287 >                  
288 >               pmapROI [n].min [0] = atof(argv [++i]);
289 >               pmapROI [n].min [1] = atof(argv [++i]);
290 >               pmapROI [n].min [2] = atof(argv [++i]);
291 >               pmapROI [n].max [0] = atof(argv [++i]);
292 >               pmapROI [n].max [1] = atof(argv [++i]);
293 >               pmapROI [n].max [2] = atof(argv [++i]);
294 >              
295 >               for (j = 0; j < 3; j++)
296 >                  if (pmapROI [n].min [j] >= pmapROI [n].max [j])
297 >                     error(USER,
298 >                           "invalid region of interest (swapped min/max?)");
299 >            }
300 > #endif            
301              else if (!strcmp(argv [i] + 2, "pP")) {
302                 /* Global photon precomputation factor */
303                 check(4, "f");
# Line 316 | Line 318 | int main (int argc, char* argv [])
318                 }
319                
320                 if (argv[i][3] == 'O') {
321 <                  /* Get port modifiers file */
321 >                  /* Get port modifiers from file */
322                    rval = wordfile(portLp, AMBLLEN-(portLp-amblist),
323                                    getpath(argv [++i], getrlibpath(), R_OK));
324                                    
# Line 409 | Line 411 | int main (int argc, char* argv [])
411                    
412              else goto badopt;
413              break;
414 <
415 < #if 0
416 <         /* Heap size increment now fixed & defined by macro in pmapkdt.c */            
417 <         case 'i': /* Photon heap size increment */
418 <            check(2, "i");
419 <            photonHeapSizeInc = atol(argv [++i]);
414 > #ifdef PMAP_EKSPERTZ
415 >         case 'l': /* Limits */
416 >            switch (argv [i][2]) {
417 >               case 'd': /* Limit photon path distance */
418 >                  check(3, "f");
419 >                  photonMaxDist = atof(argv [++i]);
420 >                  if (photonMaxDist <= 0)
421 >                     error(USER, "max photon distance must be > 0");
422 >                  break;
423 >                
424 >               case 'r': /* Limit photon bounces */              
425 >                  check(3, "i");              
426 >                  photonMaxBounce = atol(argv [++i]);
427 >                  if (photonMaxBounce <= 0)
428 >                     error(USER, "max photon bounces must be > 0");
429 >                  break;
430 >              
431 >               default: goto badopt;
432 >            }
433              break;
434 < #endif            
420 <                  
434 > #endif
435           case 'm': /* Medium */
436              switch (argv[i][2]) {
437                 case 'e':        /* Eggs-tinction coefficient */
# Line 442 | Line 456 | int main (int argc, char* argv [])
456                 default: goto badopt;
457              }                  
458              break;
459 <
460 <         case 'n': /* Num parallel processes */
459 > #if NIX
460 >         case 'n': /* Num parallel processes (NIX only) */
461              check(2, "i");
462              nproc = atoi(argv [++i]);
463              
# Line 452 | Line 466 | int main (int argc, char* argv [])
466                 sprintf(errmsg, "too many parallel processes, clamping to "
467                         "%d\n", nproc);
468                 error(WARNING, errmsg);
469 <            }
456 <            
469 >            }            
470              break;                  
471 <            
471 > #endif                        
472           case 't': /* Timer */
473              check(2, "i");
474              photonRepTime = atoi(argv [++i]);
475              break;
476 <
476 >            
477 >         case 'v':   /* Verbosity */
478 >            check_bool(2, verbose);
479 >            break;            
480   #ifdef EVALDRC_HACK
481           case 'A':   /* Angular source file */
482              check(2,"s");
483              angsrcfile = argv[++i];
484              break;                  
485 < #endif
470 <                  
485 > #endif                              
486           default: goto badopt;
487        }
488     }
# Line 507 | Line 522 | int main (int argc, char* argv [])
522        error(USER, "no photon maps specified");
523    
524     readoct(octname, loadflags, &thescene, NULL);
510
525   #ifdef EVALDRC_HACK  
526     if (angsrcfile)
527        readobj(angsrcfile);    /* load angular sources */
528 < #endif      
515 <      
528 > #endif        
529     nsceneobjs = nobjects;
530    
531     /* Get sources */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines