John Kunz | Effects Artist
Export Alembic geomtery from Houdini utilizing the visibility property

John Kunz | December 8th, 2016

Alembic is popular a file format for exchanging animation caches between different applications. It's commonly used to bring simulations and effects from Houdini to other applications like Maya, Nuke, 3dsMax, Katana, or Cinema 4D.
If your unfamiliar with Alembic, I highly suggest reading Whats so Hot About Alembic?. A quick introduction to the file format.

A frequently overlooked feature of the Alembic format is it's visiblity property. This property allows for entire scemes, objects or specific faces of an object to be flagged as either visible or hidden.

This is particularly useful for effects because it allows objects or faces to appear or disaper over time, by animating the visiblity property.
Quite commonly in Houdini, geometry will be created and deleted to show and hide it.
This can be problematic when it comes to transfering the geomtetry to another software package or rendering engine. The majority of applications and file formats aren't designed to support changing topology. They expect the same amount of objects, faces, verticies, etc. to exist on the first frame, the last frame and every frame in between. If the topology is changing, small issues can arise such as lack of motion blur, mismatched shader assignments and missing areas of geometry. In the worst of cases, it can result in freezing and crashes.

By keeping the topology consistent and simply modifying the visiblity property, all those headaches are avoided. This allows an effect with visibility which turns on or off over time to be imported in to any software package, plugin or renderer on Alembic's growing list of supported tools.

Shown below is an example of setting visiblity in Houdini and transferring to Maya.
Each cube's visiblity gets toggled off for a single frame, this is then exported from Houdini to an Alembic cache. By simply importing this cache into Maya and clicking the play button, we can see that the animated visibilty of these cubes is preserved.
This type of test can be useful to verify your visiblity animation is working as expected after being transferred between applications.




This glass breaking effect is an example where the visiblity property can be put to use.




In the image on the left, the visiblity isn't animated at all. This makes it look like the glass is broken before it even begins to shatter.
On the right, the visibility of the edge faces of the glass have animated visiblity so that they reveal the cracks as the pane breaking. This creates a much cleaner and more convincing shattering effect.




Here's some ways to manipulate Alembic's visiblity property within Houdini:

Using the Visibility SOP, this is the most straightforward method.
This operator will add any invisible primitives to a group titled "_3d_hidden_primitives". Houdini's Alembic Exporter looks for any primitives in this group and sets the Alembic propery accordingly upon export.

The Group SOP can be used to specify visibility as well, by setting the "Group Name" field to: "_3d_hidden_primitives".

The visibility status can also be set through VEX, by using a special virtual attribute in the form @group_groupname which lets you get or set group membership. This can be used to set the '_3d_hidden_primitives' group status like so:

// The following code will randomly toggle each primitive's visibility every frame i@group__3d_hidden_primitives = int(rint(random(i@primnum + f@Frame)));

Another method of manipulating a primitive's group membership in VEX is the setprimgroup function:

// The following code will randomly toggle each primitive's visibility every frame setprimgroup(geoself(), '_3d_hidden_primitives', i@primnum, int(rint(random(i@primnum + f@Frame))), 'set');

Example File ↓
export_alembic_with_visibility_poroperty.v4.hip




Additional Resources:

The Alembic::AbcGeom docs.
A discussion about the visiblity property from the alembic-dev google group.