Best way to store blend shapes data?

I'm thinking on writing a very basic blend shape deformer, and was wondering on the best way to store the deltas, in order to be fast at the time of applying them.

It seems there is not any geometry attribute designed specifically for this purpose, so my first thought was to use a generic vec3 attribute for each target.
But then I thought that if only a few vertices in the target shape have delta values, for instance 10 out of 1000, creating a whole attribute, of size 1000, just for 10 deltas, might be inefficient memory and performance wise.
But creating a struct or any other compound not stored with the geometry might also be slow.

So my question is, what approach seems more reasonable?
Are geometry attributes smart enough as to not store or not use memory for deltas with null values (0,0,0)?



  • jcgagnonjcgagnon Fabric Employee Posts: 122 Fabric Employee

    Hi Gabriel,

    There is no built-in "sparse" attribute type right now for Geometries. However, the system is made so you can build your own type of GeometryAttribute and attach it to a mesh (should specialize BaseAttribute). You probably don't need to support most of the methods in there for your use case.

    Personally the way I'd do it is with sorted indices if < 50% of the total size, else just do a full array (for speed). Sorted indices in a UInt32 array so you can do binary search, that's faster than using a KL dictionary (if optimal speed is important to you).


  • GabrielRoyGabrielRoy Posts: 42

    Thanks a lot Jerome!

Sign In or Register to comment.