Commit 7f401708 authored by Kenneth Moreland's avatar Kenneth Moreland

Merge branch 'TestImageDensity'

parents b3afdbeb 6ed42886
......@@ -46,9 +46,11 @@ typedef struct {
IceTInt num_tiles_y;
IceTInt screen_width;
IceTInt screen_height;
IceTFloat zoom;
IceTBoolean transparent;
IceTBoolean no_interlace;
IceTBoolean no_collect;
IceTBoolean dense_images;
IceTInt max_image_split;
IceTInt frame_number;
IceTDouble render_time;
......@@ -98,11 +100,13 @@ static IceTInt g_num_tiles_x;
static IceTInt g_num_tiles_y;
static IceTInt g_num_frames;
static IceTInt g_seed;
static IceTFloat g_zoom;
static IceTBoolean g_transparent;
static IceTBoolean g_colored_background;
static IceTBoolean g_no_interlace;
static IceTBoolean g_no_collect;
static IceTBoolean g_use_callback;
static IceTBoolean g_dense_images;
static IceTBoolean g_sync_render;
static IceTBoolean g_write_image;
static IceTEnum g_strategy;
......@@ -124,12 +128,14 @@ static void usage(char *argv[])
printstat(" -tilesy <num> Sets the number of tiles vertical (default 1).\n");
printstat(" -frames <num> Sets the number of frames to render (default 2).\n");
printstat(" -seed <num> Use the given number as the random seed.\n");
printstat(" -zoom <num> Set the zoom factor for the camera (larger = more zoom).\n");
printstat(" -transparent Render transparent images. (Uses 4 floats for colors.)\n");
printstat(" -colored-background Use a color for the background and correct as necessary.\n");
printstat(" -no-interlace Turn off the image interlacing optimization.\n");
printstat(" -no-collect Turn off image collection.\n");
printstat(" -use-callback Do the drawing in an IceT callback.\n");
printstat(" -sync-render Synchronize rendering by adding a barrier to the draw callback.\n");
printstat(" -dense-images Composite dense images by classifying no pixels as background.\n");
printstat(" -write-image Write an image on the first frame.\n");
printstat(" -reduce Use the reduce strategy (default).\n");
printstat(" -vtree Use the virtual trees strategy.\n");
......@@ -159,11 +165,13 @@ static void parse_arguments(int argc, char *argv[])
g_num_tiles_y = 1;
g_num_frames = 2;
g_seed = (IceTInt)time(NULL);
g_zoom = (IceTFloat)1.0;
g_transparent = ICET_FALSE;
g_colored_background = ICET_FALSE;
g_no_interlace = ICET_FALSE;
g_no_collect = ICET_FALSE;
g_use_callback = ICET_FALSE;
g_dense_images = ICET_FALSE;
g_sync_render = ICET_FALSE;
g_write_image = ICET_FALSE;
g_strategy = ICET_STRATEGY_REDUCE;
......@@ -188,6 +196,9 @@ static void parse_arguments(int argc, char *argv[])
} else if (strcmp(argv[arg], "-seed") == 0) {
arg++;
g_seed = atoi(argv[arg]);
} else if (strcmp(argv[arg], "-zoom") == 0) {
arg++;
g_zoom = (IceTFloat)atof(argv[arg]);
} else if (strcmp(argv[arg], "-transparent") == 0) {
g_transparent = ICET_TRUE;
} else if (strcmp(argv[arg], "-colored-background") == 0) {
......@@ -198,6 +209,8 @@ static void parse_arguments(int argc, char *argv[])
g_no_collect = ICET_TRUE;
} else if (strcmp(argv[arg], "-use-callback") == 0) {
g_use_callback = ICET_TRUE;
} else if (strcmp(argv[arg], "-dense-images") == 0) {
g_dense_images = ICET_TRUE;
} else if (strcmp(argv[arg], "-sync-render") == 0) {
g_sync_render = ICET_TRUE;
} else if (strcmp(argv[arg], "-write-image") == 0) {
......@@ -348,11 +361,14 @@ static void draw(const IceTDouble *projection_matrix,
IceTInt pixel_y;
IceTDouble ray_origin[3];
IceTDouble ray_direction[3];
IceTFloat background_depth;
IceTFloat background_alpha;
icetMatrixMultiply(transform, projection_matrix, modelview_matrix);
success = icetMatrixInverseTranspose((const IceTDouble *)transform,
inverse_transpose_transform);
if (!success) {
printrank("ERROR: Inverse failed.\n");
}
......@@ -376,6 +392,39 @@ static void draw(const IceTDouble *projection_matrix,
depths = icetImageGetDepthf(result);
}
if (!g_dense_images) {
background_depth = 1.0f;
background_alpha = background_color[3];
} else {
IceTSizeType pixel_index;
/* To fake dense images, use a depth and alpha for the background that
* IceT will not recognize as background. */
background_depth = 0.999f;
background_alpha
= (background_color[3] == 0) ? 0.001 : background_color[3];
/* Clear out the the images to background so that pixels outside of
* the contained viewport have valid values. */
for (pixel_index = 0; pixel_index < width*height; pixel_index++) {
if (g_transparent) {
IceTFloat *color_dest = colors_float + 4*pixel_index;
color_dest[0] = background_color[0];
color_dest[1] = background_color[1];
color_dest[2] = background_color[2];
color_dest[3] = background_alpha;
} else {
IceTUByte *color_dest = colors_byte + 4*pixel_index;
IceTFloat *depth_dest = depths + pixel_index;
color_dest[0] = (IceTUByte)(background_color[0]*255);
color_dest[1] = (IceTUByte)(background_color[1]*255);
color_dest[2] = (IceTUByte)(background_color[2]*255);
color_dest[3] = (IceTUByte)(background_alpha*255);
depth_dest[0] = background_depth;
}
}
}
ray_direction[0] = ray_direction[1] = 0.0;
ray_direction[2] = 1.0;
ray_origin[2] = -1.0;
......@@ -419,6 +468,7 @@ static void draw(const IceTDouble *projection_matrix,
/* Modify color by an opacity determined by thickness. */
IceTDouble thickness = far_distance - near_distance;
IceTDouble opacity = QUICK_OPACITY(4.0*thickness);
if (opacity < 0.001) { opacity = 0.001; }
color[0] *= (IceTFloat)opacity;
color[1] *= (IceTFloat)opacity;
color[2] *= (IceTFloat)opacity;
......@@ -428,8 +478,8 @@ static void draw(const IceTDouble *projection_matrix,
color[0] = background_color[0];
color[1] = background_color[1];
color[2] = background_color[2];
color[3] = background_color[3];
depth = 1.0f;
color[3] = background_alpha;
depth = background_depth;
}
if (g_transparent) {
......@@ -827,7 +877,7 @@ static void SimpleTimingCollectAndPrintLog()
for (log_index = 0; log_index < total_logs; log_index++) {
timings_type *timing = all_logs + log_index;
printf("LOG,%d,%s,%s,%d,%d,%d,%d,%s,%s,%s,%d,%d,%lg,%lg,%lg,%lg,%lg,%lg,%lg,%lg,%lg,%ld,%lg\n",
printf("LOG,%d,%s,%s,%d,%d,%d,%d,%0.1f,%s,%s,%s,%s,%d,%d,%lg,%lg,%lg,%lg,%lg,%lg,%lg,%lg,%lg,%ld,%lg\n",
timing->num_proc,
timing->strategy_name,
timing->si_strategy_name,
......@@ -835,9 +885,11 @@ static void SimpleTimingCollectAndPrintLog()
timing->num_tiles_y,
timing->screen_width,
timing->screen_height,
timing->zoom,
timing->transparent ? "yes" : "no",
timing->no_interlace ? "no" : "yes",
timing->no_collect ? "no" : "yes",
timing->dense_images ? "yes" : "no",
timing->max_image_split,
timing->frame_number,
timing->render_time,
......@@ -955,9 +1007,9 @@ static int SimpleTimingDoRender()
icetEnable(ICET_COLLECT_IMAGES);
}
/* Give IceT the bounds of the polygons that will be drawn. Note that IceT
* will take care of any transformation that gets passed to
* icetDrawFrame. */
/* Give IceT the bounds of the polygons that will be drawn. Note that
* IceT will take care of any transformation that gets passed to
* icetDrawFrame. */
icetBoundingBoxd(-0.5f, 0.5f, -0.5, 0.5, -0.5, 0.5);
/* Determine the region we want the local geometry to be in. This will be
......@@ -1005,7 +1057,9 @@ static int SimpleTimingDoRender()
icetSingleImageStrategy(g_single_image_strategy);
/* Set up the projection matrix. */
icetMatrixFrustum(-0.65*aspect, 0.65*aspect, -0.65, 0.65, 3.0, 5.0,
icetMatrixFrustum(-0.65*aspect/g_zoom, 0.65*aspect/g_zoom,
-0.65/g_zoom, 0.65/g_zoom,
3.0, 5.0,
projection_matrix);
if (rank%10 < 7) {
......@@ -1111,6 +1165,12 @@ static int SimpleTimingDoRender()
}
}
if (g_dense_images) {
/* With dense images, we want IceT to load in all pixels, so clear
* out the bounding box/vertices. */
icetBoundingVertices(0, ICET_VOID, 0, 0, NULL);
}
/* Get everyone to start at the same time. */
icetCommBarrier();
......@@ -1149,9 +1209,11 @@ static int SimpleTimingDoRender()
timing_array[frame].num_tiles_y = g_num_tiles_y;
timing_array[frame].screen_width = SCREEN_WIDTH;
timing_array[frame].screen_height = SCREEN_HEIGHT;
timing_array[frame].zoom = g_zoom;
timing_array[frame].transparent = g_transparent;
timing_array[frame].no_interlace = g_no_interlace;
timing_array[frame].no_collect = g_no_collect;
timing_array[frame].dense_images = g_dense_images;
timing_array[frame].max_image_split = max_image_split;
timing_array[frame].frame_number = frame;
icetGetDoublev(ICET_RENDER_TIME,
......@@ -1581,9 +1643,11 @@ int SimpleTimingRun()
"tiles y,"
"width,"
"height,"
"zoom,"
"transparent,"
"interlacing,"
"collection,"
"dense images,"
"max image split,"
"frame,"
"render time,"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment