Inspirateur / binary-greedy-meshing

A port of https://github.com/cgerikj/binary-greedy-meshing to Rust.
https://crates.io/crates/binary-greedy-meshing
MIT License
8 stars 2 forks source link

Faster transparency #4

Open Inspirateur opened 1 month ago

Inspirateur commented 1 month ago

Transparency is currently supported by manually iterating over the voxel buffer in the hidden face culling phase, using up an extra 300μs to produce a chunk mesh. We also got rid of the opacity mask which was used only to speed up the hidden face culling in the previous version.

We can implement a faster version that supports transparency by bringing back the opacity mask and by adding an extra transparency mask. We can then use leading/trailing zeroes trick to quickly iterate on the transparent bits and only check those bits in the voxel buffer.

This algorithm will perform about as fast as the original version if there are few transparent blocks in the chunk, saving us about 300μs !