Page MenuHome

Alembic export: write custom properties
ClosedPublic

Authored by Sybren A. Stüvel (sybren) on Sep 11 2020, 2:09 PM.

Details

Summary

Write custom properties (aka ID properties) on Objects and Object Data to Alembic.

Manifest Task: https://developer.blender.org/T50725

Scalar properties (so single-value/non-array properties) are written as single-element array properties to Alembic. This is also what's done by Houdini and Maya exporters, so it seems to be the standard way of doing things. It also simplifies the implementation.

Two-dimensional arrays are flattened by concatenating all the numbers into a single array. This is because ID properties have a limited type system; a 3x3 "matrix" could just as well be a list of three 3D vectors, or just three lists of three numbers without any matrix/vector semantics.

Alembic has two container properties to store custom data:

  • .userProperties, which is meant for properties that aren't necessarily understood by other software packages, and
  • .arbGeomParams, which can contain the same kind of data as .userProperties, but can also specify that these vary per face of a mesh. This property is mostly intended for renderers.

Most industry packages write their custom data to .arbGeomParams. However, given their goals I feel that .userProperties is the more appropriate one for Blender's ID Properties.

The code is a bit more involved than I would have liked. An ABCAbstractWriter has a uniqueptr to its CustomPropertiesExporter, but the CustomPropertiesExporter also has a pointer back to its owning ABCAbstractWriter. It's the latter pointer that I'm not too happy with, but it has a reason. Getting the aforementioned .userProperties from the Alembic library will automatically create it if it doesn't exist already. If it's not used to actually add custom properties to, it will crash the Alembic CLI tools (and maybe others too). This is what the pointer back to the ABCAbstractWriter is used for: to get the .userProperties at the last moment, when it's 100% sure at least one custom property will be written.

The unit tests in alembic_export_tests.py have been extended. They require the attached custom-properties.blend file to be in lib/tests/alembic.

Diff Detail

Repository
rB Blender

Event Timeline

Sybren A. Stüvel (sybren) requested review of this revision.Sep 11 2020, 2:09 PM
Sybren A. Stüvel (sybren) edited the summary of this revision. (Show Details)
  • Removed some code that shouldn't be in this patch.
source/blender/io/alembic/exporter/abc_writer_nurbs.cc
86

A bit weird to use first scheme.

Sybren says this should not be calling getUserProperties, but abc_schema_prop_for_custom_props instead.

  • Added clarification in a comment, and call the proper function abc_schema_prop_for_custom_props().

From my side seems all fine!

This revision is now accepted and ready to land.Sep 11 2020, 2:56 PM

This all sounds good to me.

I agree that .userProperties sounds like the way to go for exporting blenders custom properties

.arbGeomParams would be interesting in the future for exporting vertex groups and possibly future per vertex properties that not yet exists in Blender (string, bool etc).