assetc 0.1.0

Reads the files assetc builds and packs: textures, materials, meshes, animations, fonts, atlases and data
Documentation
  • Coverage
  • 59.71%
    449 out of 752 items documented1 out of 221 items with examples
  • Size
  • Source code size: 232.2 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 5.1 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 4s Average build duration of successful builds.
  • all releases: 3s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • qbart

assetc

The runtime SDK of assetc, the asset compiler. Learn more about the project, its GUI and every source and output format in the main README.

The project

assetc compiles source assets (textures, meshes, shaders, materials, fonts) into runtime-friendly binary formats for video games. Supports octahedral-packed normals/tangents and meshletized geometry; mesh files reference materials by stable 64-bit hashes so the engine can share resources across assets. Mesh additionally emits a companion material table plus one content-addressed .ktx2 per referenced image. Embedded textures are written to a shared flat store keyed by content, so the same texture used by two different models is encoded once and shares one runtime handle.

Texture refs are stored as 64-bit hashes, not paths. A single global manifest maps each hash back to the file on disk. Load it once into a hash → path map and you can resolve any asset by a stable id - textures (baseColorTex etc.), but also meshes, materials, animations, fonts, shaders, and embeds - through one uniform lookup.

What the SDK does

assetc runs at build time; this crate runs in your game. It reads everything assetc build and assetc pack write, so the game never parses a binary layout itself:

  • Opens the assets from a .pak (the whole output in one file) or from an output directory, the same way, so you can ship a pack and develop against loose files.
  • Lists and finds them by kind, by asset ID (the stable 64-bit hash every asset and reference uses) or by output path.
  • Decodes every format into plain Rust values: KTX2 textures with all mip levels, PBR and custom materials, meshes (vertices with unpacked normals and tangents, meshlets, levels of detail, skin, locators, shapes, regions, paths), animations (with sampling), SDF fonts (with text layout), atlases, gradients (with sampling), palettes, shader interfaces with SPIR-V, schemas, data instances, graphs, trees and attached structs.
  • Stays engine-neutral and light: no dependencies but std. Turning the values into GPU resources is your engine's part; the repository's demo does it for Bevy.

The format specs it follows are in docs/spec/, and its API in docs/features/sdk.md.

Usage

[dependencies]
assetc = "0.1"
use assetc::{Assets, Kind, Mesh, Texture};

fn main() -> assetc::Result<()> {
    // A `.pak` from `assetc pack`, or the output directory of `assetc build`.
    let assets = Assets::open("build/assetc.pak")?;
    for entry in assets.of_kind(Kind::Mesh) {
        let mesh: Mesh = assets.load(entry.id)?;
        println!("{}: {} vertices", entry.path, mesh.vertices.len());
    }
    let texture: Texture = assets.load_path("ui/fire.ktx2")?;
    println!("{}x{}", texture.width, texture.height);
    Ok(())
}

Licensed under either of MIT (LICENSE-MIT) or Apache-2.0 (LICENSE-APACHE), at your option.