google / draco

Draco is a library for compressing and decompressing 3D geometric meshes and point clouds. It is intended to improve the storage and transmission of 3D graphics.
https://google.github.io/draco/
Apache License 2.0
6.47k stars 962 forks source link

FR: Add more granular "encoder.SetAttributeQuantization()" API for GeometryAttribute::GENERIC attributes #1024

Closed sessamekesh closed 11 months ago

sessamekesh commented 1 year ago

I'd love to be able to set quantization per-attribute for generic attributes, especially skeletal animation parameters bone_idx and bone_weight.

Background

I currently use a handful of custom GeometryAttribute::GENERIC attributes, and have been happy enough to use default quantization settings for all of them - compression rate is not a major pain point for me.

Some of my models get quite large though, even with Draco compression, and I'd love the ability to tweak the quantization level for custom properties.

Proposal 1: Add an Encoder::SetIndividualAttributeQuantization(GeometryAttribute::Type, int attribute_idx, int quantization_bits) method

The three most common GENERIC attributes I use:

A cursory internet search suggests that my use cases of vertex tangents and skeleton bindings are both pretty common use cases for GeometryAttribute::GENERIC.

I favor this approach, since it fits the common use cases and is extensible to uncommon ones as well.

Proposal 2: Add BONE_INDEX and BONE_WEIGHT attribute types

Skeletal animation for 3D assets is a common enough use case to justify a special distinction. There isn't a lot of insanely fancy compression to be had here, but BONE_INDEX data can usually fit in 4-6 bits, and I suspect BONE_WEIGHT data can be fairly aggressively quantized as it's often a normal 4D vector.

sessamekesh commented 1 year ago

I'm also happy to make a PR for these, with just a touch of guidance from the Draco team 🙂

ondys commented 11 months ago

There is a more granular API already. See ExpertEncoder where you can set quantization setting for a specific attribute index (not attribute type). That should be sufficient for your requirments.