๐Ÿ“ฆ bevyengine / bevy_mikktspace

A safe Rust implementation of the Mikkelsen Tangent Space Algorithm.

โ˜… 2 stars โ‘‚ 3 forks ๐Ÿ‘ 2 watching โš–๏ธ Apache License 2.0
๐Ÿ“ฅ Clone https://github.com/bevyengine/bevy_mikktspace.git
HTTPS git clone https://github.com/bevyengine/bevy_mikktspace.git
SSH git clone git@github.com:bevyengine/bevy_mikktspace.git
CLI gh repo clone bevyengine/bevy_mikktspace
atlv atlv update version shield (#9) 2946802 5 months ago ๐Ÿ“ History
๐Ÿ“‚ main View all commits โ†’
๐Ÿ“ .github
๐Ÿ“ benches
๐Ÿ“ data
๐Ÿ“ examples
๐Ÿ“ fuzz
๐Ÿ“ src
๐Ÿ“ tests
๐Ÿ“„ .gitattributes
๐Ÿ“„ .gitignore
๐Ÿ“„ Cargo.toml
๐Ÿ“„ LICENSE-APACHE
๐Ÿ“„ LICENSE-MIT
๐Ÿ“„ README.md
๐Ÿ“„ rustfmt.toml
๐Ÿ“„ README.md

Bevy Mikktspace

License Crates.io Downloads Docs Discord

This is a rewrite of the Mikkelsen Tangent Space Algorithm reference implementation in Rust. It is loosely based on mikktspace, an existing port, except bevy_mikktspace has:

  • exact byte-for-byte output equivalence with the original C source under all conditions[^1].
  • fully idiomatic rust with no unsafe code, to support building in no-unsafe contexts.
  • no dependencies, to avoid needing perpetual dependency-version-bump releases in the future.
Requires at least Rust 1.85.1.

Examples

cube_tangents

Demonstrates generating tangents for a cube with 4 triangular faces per side.

cargo run --example cube_tangents

Features

The original reference implementation has a couple bugs, which are largely inconsequential in most practical applications. However, fixing them would mean diverging from exact output equivalence, so bevy_mikktspace offers features to control this behavior:

  • corrected-edge-sorting:
Correct a comparison in the reference's edge quicksort implementation. This can only differ on the last triangle in a model.
  • corrected-vertex-welding:
Guarantees the smallest-index vertex is chosen when welding. This differs from the reference on NaN vertices.

License agreement

Licensed under either of

  • Apache License, Version 2.0
(LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license
(LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option. AND parts of the code are licensed under:

  • Zlib license
https://opensource.org/licenses/Zlib

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

[^1]: Extensive fuzz-testing against the reference implementation revealed divergence in NaN handling in https://github.com/gltf-rs/mikktspace, which is probably inconsequential for practical uses.