FractalFir / FractalFir/tmf

[FEATURE] Support arbitrary vertex attributes

Open
#7 6 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
118
Forks
8
PR merge metrics
No merged PRs in 30d

Description

TMF looks super cool!

But I'd not only want to store **normal, positions and uvs** data. Formats like glTF also store other attributes per vertex, such as: **color, tangent, secondary uvs, skeletal animation bone weights**.

Game engines do use more than normal position and uvs, and it seems reasonable to expect from a mesh serialization format that it supports additional attributes.

### Implementation

I'm conscious this is not a trivial task, because each attribute can have an arbitrary representation. And it probably makes it hard to apply some useful heuristics. So I'm not adventuring to propose an implementation. But the most basic API I'd like is a method on `TMFMesh` that does:

```rust
fn set_attribute(&mut self, attribute_id: usize, buffer: &[T]) {}
fn get_attribute(&self, attribute_id: usize) -> Option<&[T]> {}
```

(this is an extremely primitive API that can fairly trivially be improved, not a template for a final API)

A method on `VertexAttribute` could provide to `TMFMesh` informations so that it can apply good compression heuristics, and specifically allow erasing the type (so that it could be internally stored as a `Box<[u8]>` and cast when accessed)

### What is this for?

I'm maintaining the `bevy_fbx` crate and bevy is landing a new asset loader with a post-processing step. The FBX format suuuuucks and is wasteful when it comes to game assets (it even leaks private information), using an intermediary representation **that is fast to write and read from* is a necessity tbh.

My fbx loader currently only supports normal positions and uvs, so I already can use TMF! However, storing tangents in the backed meshes would be super useful, it would allow not having to compute tangents at runtime, which can be fairly expensive.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.