Skip to content

Commit

Permalink
Fix build break.
Browse files Browse the repository at this point in the history
  • Loading branch information
Philip Rideout committed Aug 16, 2015
1 parent b42794a commit 699ce72
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 4 additions & 1 deletion include/heman.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/generate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
28 changes: 24 additions & 4 deletions src/ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/test_heman.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 699ce72

Please sign in to comment.