binary-greedy-meshing
For now this is simply a port of Binary Greedy Meshing v2 to Rust, but improvements to API are planned for the future (see issues).
How to use
This crate is used in the Bevy voxel game Riverbed, you can check out the code for usage examples.
Minimal example
use binary_greedy_meshing as bgm;
What to do with mesh_data.quads
mesh_data.quads
is a Vec<u64>
, each u64 encodes all the information of a quad in the following manner:
| | | | | x
The quad Vec is grouped into 6 parts, 1 for each face type, which are delimited by these fields:
The face groups correspond to Up, Down, Right, Left, Front, Back, in this order. (assuming right handed Y up)
The fastest way of rendering quads is using instancing (check this video to learn more about the topic), but if it's not available you can still convert the quads to vertices and indices making a regular mesh, see this Riverbed files for an example of this:
- src/render/mesh_utils.rs for Face+Quad => vertices conversion
- src/render/mesh_chunks.rs for the rest of the meshing code (+ LOD)
Performance
Profiling info from Riverbed's usage of the crate on Intel(R) Xeon(R) CPU E5-1650 v3 @ 3.50GHz:
- opacity mask building: 300μs (can be cached)
- meshing itself: 300μs
This is close to the 50-200μs range reported (for meshing) by folks from the original C version of the library.
chunk sizes are 623 (643 with padding), this crate doesn't support other sizes.