48 cerr <<
"Usage: " << program <<
"\n\t-t <light transform> \n";
49 cerr <<
"\t-x <x resolution> -y <y resolution>\n";
50 cerr <<
"\t-l <projection type> <focal length> <aperture> <ortho width>\n";
51 cerr <<
"\t-i <I3D file>\n";
52 cerr <<
"\t-f <DSM file>\n";
53 cerr <<
"\t[-s <Step size>]\n";
54 cerr <<
"\t[-d <Max Depth>]\n";
60 float dist,
float step,
float tau)
63 float den, pden, zval, zinc;
71 i3d.
integrate(p0, p1, pixel, 0.001F, 1, 0);
72 i3d.
integrate(p1, p0, pixel, 0.001F, 1, 0);
75 if (
dot(p1-p0, dir) <= 0)
78 nsteps = (
int)((p1-p0).length() / step);
80 fprintf(stderr,
"Integrating %d steps (from %f %f %f to %f %f %f)\n",
81 nsteps, p0[0], p0[1], p0[2], p1[0], p1[1], p1[2]);
85 zinc = step*dir.length();
87 for (i = 0; i < nsteps; i++)
90 i1 = p0 + (
float)i*step*dir;
95 pden = den + (1-den)*pden;
96 pixel[0] = pixel[1] = pixel[2] = pden;
98 fprintf(stderr,
"Storing pixel data: %f %f %f %f\n",
99 pixel[0], pixel[1], pixel[2], pixel[3]);
116 float dist, step, zoom, xwin, ywin, tau, orthow;
132 fname = args.
argp(
'f');
134 iname = args.
argp(
'i');
136 step = args.
fargp(
's');
138 dist = args.
fargp(
'd');
148 cerr <<
"Invalid transform parameters "
149 "(example: [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])\n";
153 for (i = 0; i < 4; i++)
154 for (j = 0; j < 4; j++)
155 trans(i, j) = atof(argv[i*4+j]);
159 cerr <<
"Must specify global transformation (-t)\n";
166 xres = args.
iargp(
'x', 0);
167 yres = args.
iargp(
'y', 0);
168 ortho = args.
iargp(
'l', 0) == 1;
171 orthow = args.
fargp(
'l', 3);
176 if (args.
fargp(
'l', 2) == 0)
178 cerr <<
"Must specify non-zero light aperture\n";
182 zoom = args.
fargp(
'l', 1) / args.
fargp(
'l', 2);
187 cerr <<
"Must specify light parameters\n";
192 if (!fname || !iname)
194 cerr <<
"Must specify DSM and I3D file names\n";
201 cerr <<
"Could not open I3D texture " << iname <<
"\n";
207 cerr <<
"Could not open density channel of " << iname <<
"\n";
212 std::cout <<
"Creating DSM " << fname <<
" from i3d " << iname <<
"\n";
214 xwin = orthow * 0.5F / zoom;
215 ywin = xwin * (yres / (
float)xres);
219 dsm.
setOption(
"depth_planes",
"zfront,zback");
220 dsm.
create(fname, xres, yres, 1, 1);
226 for (j = 0; j < yres; j++)
228 for (i = 0; i < xres; i++)
230 dir =
UT_Vector3(xwin*2*(i+0.5F)/(
float)xres-xwin,
231 ywin*2*(j+0.5F)/(
float)yres-ywin, -1);
235 fillPixel(writer, i3d, orig, dir, dist, step, tau);
244 for (j = 0; j < yres; j++)
246 for (i = 0; i < xres; i++)
248 orig =
UT_Vector3(xwin*2*(i+0.5F)/(
float)xres-xwin,
249 ywin*2*(j+0.5F)/(
float)yres-ywin, 0);
253 fillPixel(writer, i3d, orig, dir, dist, step, tau);
int iargp(int opt, int which=0) const
int theMain(int argc, char *argv[])
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
GA_API const UT_StringHolder dist
UT_Matrix3T< double > UT_DMatrix3
void setOption(const char *option, const UT_StringHolder &value)
UT_Vector3T< float > UT_Vector3
void stripOptions(const char *options)
Thread-safe convenience class to make writing DSM pixels easy.
int openChannel(const char *channel_name)
GLuint GLsizei GLsizei * length
Class to read or write deep shadow/camera images.
bool create(const char *name, int xres, int yres, int sxres, int syres, float pixel_aspect=1.0, const UT_DimRect *crop=NULL)
fpreal fargp(int opt, int which=0) const
IMATH_NAMESPACE::V2f float
int tokenize(char *argv[], int max_args, char separator)
GA_API const UT_StringHolder trans
fpreal64 dot(const CE_VectorT< T > &a, const CE_VectorT< T > &b)
SYS_FORCE_INLINE void rowVecMult3(const UT_Matrix4F &m)
bool open(int x, int y)
Open a pixel for writing.
auto fprintf(std::FILE *f, const S &fmt, const T &...args) -> int
int sample(const UT_Vector3 &pos, float *result)
GLsizeiptr const void GLenum usage
int integrate(UT_Vector3 &p0, UT_Vector3 &p1, float *result, fpreal limit_max=1, fpreal value_scale=1, fpreal accuracy=0)
int openTexture(const char *filename)
**If you just want to fire and args
const char * argp(int opt, int which=0) const
void initialize(int argc, const char *const argv[])
Class to handle reading/writing 3D texture images.
GLbitfield GLuint program
bool writeOrdered(float z, const float *chdata, int chsize, int flags, int sampleid, float dz=0)
void getTranslates(UT_Vector3T< S > &translates) const