MergeEquivalentIndexedValues

Hello OpenUsd,

The maya plugin has a very useful function to compress value arrays into value arrays + indices:

Does something like this exist in the Usd code base? If not is there a way some of this code could be contributed to OpenUsd so this is also available outside of the Maya plugin code ( without re-introducing boost :wink: ) ?

Thanks,
Koen

Nope, nothing like this in OpenUSD! If this is being used primarily for data storage/access optimization, it gets tricky to know for sure whether you’re helping or hurting. E.g. doing this on float-arrays, or any other 4-byte-word data is actually going to be pure hurt… unless there’s alot of duplication and your application really leverages the identification of duplicate entries, rather than just wanting smaller bandwidth/footprint to the data.

But we’d be open to considering a UsdUtils contribution!

thanks spiff, I found for attributes with varying interpolation that are often smooth ( normals, tangents, bi-tangents, colors etc ) the indices can help a lot. For smaller data types there is less to gain, as you add an integer array as well. For most vec3 and vec4 data types, there is a significant storage advantage for us.

I’ll see if we can perhaps adjust our internal code to work on usd data types and ask permission to contribute. To be continued, thanks!

Koen

We have a function for indexing primvars in NVIDIA OpenUSD Exchange SDK.

If you’re comfortable adding that dependency, feel free to use it. Otherwise, the source is on GitHub, feel free to be inspired by it. The PrimvarData.h/inl can be easily pulled out of the library (they only include regular pxr headers).

Nice, I’ll take a look, thanks Andrew!

Koen