Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/prideout/heman
C99 heightmap utilities.
https://github.com/prideout/heman
distance-field graphics heightmap
Last synced: about 2 months ago
JSON representation
C99 heightmap utilities.
- Host: GitHub
- URL: https://github.com/prideout/heman
- Owner: prideout
- License: mit
- Created: 2015-08-09T23:12:29.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2021-04-27T22:43:51.000Z (about 3 years ago)
- Last Synced: 2024-02-01T08:46:20.847Z (5 months ago)
- Topics: distance-field, graphics, heightmap
- Language: C
- Homepage: https://prideout.net/heman/
- Size: 6.58 MB
- Stars: 457
- Watchers: 28
- Forks: 24
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-c - heman - Tiny library of image utilities dealing with height maps, normal maps, distance fields and the like. [`Expat`](https://directory.fsf.org/wiki/License:Expat) (Graphics ## / Resources ###)
- AwesomeCppGameDev - heman
- awesome-c-zh - heman - 处理高度图的图像实用程序的微型库,法线贴图,距离场等。[](https://spdx.org/licenses/MIT.html) (图形)
README
![](https://github.com/prideout/heman/blob/master/docs/_static/islands.png)
This toy project is a tiny MIT-licensed C library of image utilities for dealing with **he**ight
**ma**ps, **n**ormal maps, distance fields, and the like. It has a very low-level API, where an
"image" is simply a flat array of floats. There are no dependencies and [only one header
file](https://github.com/prideout/heman/blob/master/include/heman.h).**Heman** can do stuff like this:
- Create a random height field using simplex noise and FBM.
- Generate a normal map from a height map.
- Compute ambient occlusion from a height map.
- Generate a signed distance field (SDF).
- Export a 3D mesh in [PLY](http://paulbourke.net/dataformats/ply/) format.
- Apply a color gradient to a heightmap.
- Generate a color gradient, given a list of control points.
- Compute diffuse lighting with an infinite light source.
- Generate a nicely-distributed list of points according to a density field.Heman implements some really nice 21st-century algorithms:
- Ambient occlusion is generated using Sean Barrett's efficient method that makes 16 sweeps over the
height field.
- Distance field computation uses the beautiful algorithm from _Distance Transforms of Sampled
Functions_ (Felzenszwalb and Huttenlocher).
- Density field samples are generated using Robert Bridson's _Fast Poisson Disk Sampling in
Arbitrary Dimensions_.## Example
The images at the top were generated from code that looks like this:
```c
// Generate an island shape using simplex noise and a distance field.
heman_image* elevation = heman_generate_island_heightmap(1024, 1024, rand());// Compute ambient occlusion from the height map.
heman_image* occ = heman_lighting_compute_occlusion(elevation);// Visualize the normal vectors.
heman_image* normals = heman_lighting_compute_normals(elevation);// Apply a color gradient.
heman_image* gradient = heman_color_create_gradient(...);
heman_image* albedo = heman_color_apply_gradient(elevation, -0.5, 0.5, grad);// Apply diffuse lighting.
heman_image* final = heman_lighting_apply(elevation, albedo, ...);
```For the unabridged version, see `test_lighting()` in
[test/test_heman.c](https://github.com/prideout/heman/blob/master/test/test_heman.c).## Building OpenMP
```
curl -L -O https://github.com/llvm/llvm-project/releases/download/llvmorg-12.0.0/openmp-12.0.0.src.tar.xz
tar -xvf openmp-12.0.0.src.tar.xz ; rm openmp-12.0.0.src.tar.xz
cd openmp-12.0.0.src
cmake . -DLIBOMP_ENABLE_SHARED=OFF -DLIBOMP_INSTALL_ALIASES=OFF -DCMAKE_OSX_ARCHITECTURES=x86_64
sudo make install
```