1 unstable release
new 0.0.1 | Mar 27, 2025 |
---|
#21 in #3d-model
51 downloads per month
5MB
883 lines
🌐 Universal Game Model
Universal game model is a minimal crate designed as a high performance model format. Loading times can be very slow when repeatedly parsing a glTF model into a custom engine representation over and over each time a game is loaded up. Ugm solves this by allowing you to convert a glTF model into a ugm model once at bake time, after which it can be loaded directly as is with a 10x performance improvement!
Features
- glTF parsing
- Bc texture compression
- Normal & tangent generation
- Vertex packing
- Mipmap generation
- Astc texture compression
Usage
Serialization and deserialization are handled by speedy. For more info please look at their docs.
use ugm::{parser::ParseOptions, texture::TextureCompression, Model};
// Get the bytes of your model, more commonly you'd read it from a file
let gltf_model_bytes: &[u8; 0] = include_bytes!("ToyCar.glb");
// Parse a glTF model into a ugm model, this is relatively slow and shouldn't happen each time the application is launched
let ugm_model: Model = Model::parse_glb(
gltf_model_bytes,
ParseOptions {
// Optional texture compression, this will increase parse duration
texture_compression: Some(TextureCompression::Bc),
},
)
.expect("Failed to parse glTF model.");
// Serialize ugm model into bytes
let ugm_model_bytes: Vec<u8> = ugm_model.write_to_vec().unwrap();
// Here you'd want to write out the serialized ugm model, which can then be loaded the next times the application is launched...
// Deserialize bytes into a ugm model
let ugm_model = Model::read_from_buffer(&ugm_model_bytes).unwrap();
Dependencies
~40–70MB
~672K SLoC