From 699ce72da4fd8abb86edabe3a3e2129cd3f09b22 Mon Sep 17 00:00:00 2001 From: Philip Rideout Date: Sun, 16 Aug 2015 16:14:48 -0700 Subject: [PATCH] Fix build break. --- docs/overview.rst | 2 +- include/heman.h | 5 ++++- src/generate.c | 2 +- src/ops.c | 28 ++++++++++++++++++++++++---- test/test_heman.c | 2 +- 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/docs/overview.rst b/docs/overview.rst index b38fefe..8a96ab9 100644 --- a/docs/overview.rst +++ b/docs/overview.rst @@ -7,11 +7,11 @@ Heman is a C library of image utilities for dealing with height maps and other f Heman can be used for: +* Creating random height fields using simplex noise and FBM. * Generating a normal map from a height map using forwarding differencing. * Efficiently computing ambient occlusion from a height map. * Generating a signed distance field (SDF) using a `fast algorithm`_. * Exporting a 3D mesh in PLY_ format. -* Creating images from scratch using simplex noise and Fractional Brownian Motion. * Applying a color gradient to a heightmap (LUT). * Generating a color gradient, given a list of control points. * Computing diffuse lighting with an infinite light source. diff --git a/include/heman.h b/include/heman.h index b94d8c9..1f0ca80 100644 --- a/include/heman.h +++ b/include/heman.h @@ -94,7 +94,10 @@ void heman_export_u8( heman_image* source, HEMAN_FLOAT minv, HEMAN_FLOAT maxv, heman_byte* outp); // Given a set of same-sized images, copy them into a horizontal filmstrip. -heman_image* heman_ops_stitch(heman_image** images, int count); +heman_image* heman_ops_stitch_horizontal(heman_image** images, int count); + +// Given a set of same-sized images, copy them into a vertical filmstrip. +heman_image* heman_ops_stitch_vertical(heman_image** images, int count); // Transform texel values so that [minval, maxval] map to [0, 1] and return the // result. Values outside the range are clamped. The source image is diff --git a/src/generate.c b/src/generate.c index ade7b98..6b7f192 100644 --- a/src/generate.c +++ b/src/generate.c @@ -157,7 +157,7 @@ heman_image* heman_generate_planet_heightmap(int width, int height, int seed) HEMAN_FLOAT antarctic_influence = MAX(10 * (v - s) / s, -0.5); v = fabs(v - 0.5); v = 1.5 * (0.5 - v); - equatorial_influence = v * v; + float equatorial_influence = v * v; v = y * scaley; for (int x = 0; x < width; ++x) { float u = x * scalex; diff --git a/src/ops.c b/src/ops.c index fc11523..9bed815 100644 --- a/src/ops.c +++ b/src/ops.c @@ -53,7 +53,7 @@ static void copy_row(heman_image* src, heman_image* dst, int dstx, int y) } } -heman_image* heman_ops_stitch(heman_image** images, int count) +heman_image* heman_ops_stitch_horizontal(heman_image** images, int count) { assert(count > 0); int width = images[0]->width; @@ -67,10 +67,30 @@ heman_image* heman_ops_stitch(heman_image** images, int count) #pragma omp parallel for for (int y = 0; y < height; y++) { - int x = 0; for (int tile = 0; tile < count; tile++) { - copy_row(images[tile], result, x, y); - x += width; + copy_row(images[tile], result, tile * width, y); + } + } + + return result; +} + +heman_image* heman_ops_stitch_vertical(heman_image** images, int count) +{ + assert(count > 0); + int width = images[0]->width; + int height = images[0]->height; + for (int i = 0; i < count; i++) { + assert(images[i]->width == width); + assert(images[i]->height == height); + assert(images[i]->nbands == 1 || images[i]->nbands == 3); + } + heman_image* result = heman_image_create(width, height * count, 3); + +#pragma omp parallel for + for (int y = 0; y < height; y++) { + for (int tile = 0; tile < count; tile++) { + copy_row(images[tile], result, 0, y + height * tile); } } diff --git a/test/test_heman.c b/test/test_heman.c index f2e821e..29ebe32 100644 --- a/test/test_heman.c +++ b/test/test_heman.c @@ -129,7 +129,7 @@ static void test_lighting() heman_lighting_apply(hmap, albedo, 1, 1, 0.5, lightpos); heman_image* frames[] = {hmapviz, occ, normviz, albedo, final}; - heman_image* filmstrip = heman_ops_stitch(frames, 5); + heman_image* filmstrip = heman_ops_stitch_horizontal(frames, 5); hut_write_image(OUTFOLDER "filmstrip.png", filmstrip, 0, 1); heman_export_ply(hmap, OUTFOLDER "heightmap.ply"); heman_export_with_colors_ply(hmap, final, OUTFOLDER "colors.ply");