11 |
|
#include <stdio.h> |
12 |
|
#include <stdlib.h> |
13 |
|
#include <math.h> |
14 |
+ |
#include "random.h" |
15 |
|
#include "platform.h" |
16 |
+ |
#include "rtprocess.h" |
17 |
|
#include "calcomp.h" |
18 |
|
#include "bsdfrep.h" |
19 |
|
/* global argv[0] */ |
26 |
|
const double ssamp_thresh = 0.35; |
27 |
|
/* number of super-samples */ |
28 |
|
const int nssamp = 100; |
29 |
+ |
/* limit on number of RBF lobes */ |
30 |
+ |
static int lobe_lim = 15000; |
31 |
|
|
32 |
|
/* Output XML prologue to stdout */ |
33 |
|
static void |
46 |
|
puts("<Optical>"); |
47 |
|
puts("<Layer>"); |
48 |
|
puts("\t<Material>"); |
49 |
< |
puts("\t\t<Name>Name</Name>"); |
50 |
< |
puts("\t\t<Manufacturer>Manufacturer</Manufacturer>"); |
49 |
> |
printf("\t\t<Name>%s</Name>\n", bsdf_name[0] ? bsdf_name : "Unknown"); |
50 |
> |
printf("\t\t<Manufacturer>%s</Manufacturer>\n", |
51 |
> |
bsdf_manuf[0] ? bsdf_manuf : "Unknown"); |
52 |
|
puts("\t\t<DeviceType>Other</DeviceType>"); |
53 |
|
puts("\t</Material>"); |
54 |
|
puts("\t<DataDefinition>"); |
125 |
|
|
126 |
|
data_prologue(); /* begin output */ |
127 |
|
if (pctcull >= 0) { |
128 |
< |
sprintf(cmd, "rttree_reduce -h -a -ff -r 3 -t %f -g %d", |
128 |
> |
sprintf(cmd, "rttree_reduce -a -h -ff -r 3 -t %f -g %d", |
129 |
|
pctcull, samp_order); |
130 |
|
fflush(stdout); |
131 |
|
ofp = popen(cmd, "w"); |
147 |
|
iovec[1] = .0; |
148 |
|
iovec[2] = input_orient * sqrt(1. - iovec[0]*iovec[0]); |
149 |
|
if (funame == NULL) |
150 |
< |
rbf = advect_rbf(iovec); |
150 |
> |
rbf = advect_rbf(iovec, lobe_lim); |
151 |
|
for (ox = 0; ox < sqres; ox++) { |
152 |
|
float last_bsdf = -1; |
153 |
|
for (oy = 0; oy < sqres; oy++) { |
170 |
|
if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) { |
171 |
|
sum = 0; /* super-sample voxel */ |
172 |
|
for (ssi = nssamp; ssi--; ) { |
173 |
< |
SDmultiSamp(ssa, 3, (ssi+drand48())/nssamp); |
173 |
> |
SDmultiSamp(ssa, 3, (ssi+frandom())/nssamp); |
174 |
|
ssvec[0] = 2.*(ix+ssa[0])/sqres - 1.; |
175 |
|
ssvec[1] = .0; |
176 |
|
ssvec[2] = input_orient * |
229 |
|
|
230 |
|
data_prologue(); /* begin output */ |
231 |
|
if (pctcull >= 0) { |
232 |
< |
sprintf(cmd, "rttree_reduce -h -a -ff -r 4 -t %f -g %d", |
232 |
> |
sprintf(cmd, "rttree_reduce%s -h -ff -r 4 -t %f -g %d", |
233 |
> |
(input_orient>0 ^ output_orient>0) ? "" : " -a", |
234 |
|
pctcull, samp_order); |
235 |
|
fflush(stdout); |
236 |
|
ofp = popen(cmd, "w"); |
252 |
|
iovec[2] = input_orient * |
253 |
|
sqrt(1. - iovec[0]*iovec[0] - iovec[1]*iovec[1]); |
254 |
|
if (funame == NULL) |
255 |
< |
rbf = advect_rbf(iovec); |
255 |
> |
rbf = advect_rbf(iovec, lobe_lim); |
256 |
|
for (ox = 0; ox < sqres; ox++) { |
257 |
|
float last_bsdf = -1; |
258 |
|
for (oy = 0; oy < sqres; oy++) { |
275 |
|
if (abs_diff(bsdf, last_bsdf) > ssamp_thresh) { |
276 |
|
sum = 0; /* super-sample voxel */ |
277 |
|
for (ssi = nssamp; ssi--; ) { |
278 |
< |
SDmultiSamp(ssa, 4, (ssi+drand48())/nssamp); |
278 |
> |
SDmultiSamp(ssa, 4, (ssi+frandom())/nssamp); |
279 |
|
SDsquare2disk(ssvec, 1.-(ix+ssa[0])/sqres, |
280 |
|
1.-(iy+ssa[1])/sqres); |
281 |
|
ssvec[2] = output_orient * |
362 |
|
case 'g': |
363 |
|
samp_order = atoi(argv[++i]); |
364 |
|
break; |
365 |
+ |
case 'l': |
366 |
+ |
lobe_lim = atoi(argv[++i]); |
367 |
+ |
break; |
368 |
|
default: |
369 |
|
goto userr; |
370 |
|
} |
375 |
|
fprintf(stderr, |
376 |
|
"%s: need single function with 6 arguments: bsdf(ix,iy,iz,ox,oy,oz)\n", |
377 |
|
progname); |
378 |
< |
fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n", |
370 |
< |
progname); |
378 |
> |
fprintf(stderr, "\tor 3 arguments using Dx,Dy,Dz: bsdf(ix,iy,iz)\n"); |
379 |
|
goto userr; |
380 |
|
} |
381 |
|
++eclock; |
431 |
|
return(0); |
432 |
|
userr: |
433 |
|
fprintf(stderr, |
434 |
< |
"Usage: %s [-g Nlog2][-t pctcull] [bsdf.sir ..] > bsdf.xml\n", |
434 |
> |
"Usage: %s [-g Nlog2][-t pctcull][-l maxlobes] [bsdf.sir ..] > bsdf.xml\n", |
435 |
|
progname); |
436 |
|
fprintf(stderr, |
437 |
|
" or: %s -t{3|4} [-g Nlog2][-t pctcull][{+|-}for[ward]][{+|-}b[ackward]][-e expr][-f file] bsdf_func > bsdf.xml\n", |