#game-engine #bevy #png #mesh #load #heightmap #height

bevy_heightmap

Create meshes from heightmap PNGs in the Bevy game engine

6 releases

new 0.3.0 Dec 1, 2024
0.2.3 Aug 5, 2024
0.2.1 Jul 15, 2024
0.1.0 Jul 15, 2024

#685 in Game dev

Download history 5/week @ 2024-09-20 7/week @ 2024-09-27 1/week @ 2024-10-04 3/week @ 2024-11-01 1/week @ 2024-11-08 156/week @ 2024-11-29

158 downloads per month

MIT/Apache

3MB
202 lines

bevy_heightmap

License Crates.io Docs

Load height map PNGs as meshes in bevy.

Height map Generated
example_image example_image

Usage

Create a height map from a value function:

use bevy::prelude::*;
use bevy_heightmap::*;
let heightmap = HeightMap {
  size: UVec2::new(10, 10),
  h: |p: Vec2| ((20. * p.x).sin() + (20. * p.y).sin()) / 2.
};
let mesh: Mesh = heightmap.into();
assert_eq!(mesh.count_vertices(), 4 * 10 * 10);

Load a height map as a mesh from an image (requires .hmp.png extension):

use bevy::prelude::*;
use bevy_heightmap::*;
fn setup(asset_server: Res<AssetServer>) {
    let mesh: Handle<Mesh> = asset_server.load("textures/terrain.hmp.png");
}

Examples

cargo run --example image

Bevy support table

bevy bevy_heightmap
0.15 0.3.0
0.14 0.2.0
0.13 0.1.0

Dependencies

~24–35MB
~575K SLoC