Using subcompositions inside of other compositions

If you find yourself copying and pasting the same group of nodes and cables into many compositions, you may want to turn those nodes and cables into a subcomposition. A subcomposition is a composition that can be used as a node inside of other compositions. A subcomposition saves you the effort of having to recreate the same nodes and cables over and over. They’re packaged neatly inside a node, which you can drag from the Node Library onto your canvas just like any other node.

Let’s walk through an example. Suppose you often draw hemispheres (half spheres) in your 3D compositions, and it would be convenient to have a Make Hemisphere node in your Node Library. The first step is to identify the nodes and cables that you want to package into a subcomposition.

The composition above renders two rotating hemispheres to a window. (The Trim 3D Object node cuts off half of the sphere. The Show Back of 3D Object node makes the inside of the sphere visible.)

In other compositions, you may want to create any number of hemispheres. The hemispheres could have different rotations, positions, sizes, and colors. They could be rendered to a window or an image. So, for the subcomposition, let’s choose a piece of the composition that’s flexible enough to be used in all of these scenarios: the nodes and cables tinted magenta.

New in Vuo 2.0

To turn these nodes and cables into a subcomposition, select them, then right-click on them and go to Package as Subcomposition.

This extracts the selected part of the composition into a new window, where you’re asked to pick a name for the subcomposition.

Having named the subcomposition, you now have two windows: one with the subcomposition and one with the original composition, in which the selected part has been replaced with a subcomposition node.

In the original composition, the nodes and cables outside of the selected part (which was packaged into a subcomposition) connected to the selected part at three points of contact:

When the selected part was packaged into a subcomposition, these three points of contact became published input and output ports within the Make Hemisphere subcomposition. Correspondingly, they became input and output ports on the Make Hemisphere node.

Now that you have a Make Hemisphere node available, you can search for it in the Node Library and add more instances of it to your composition.

Package as Subcomposition installs the subcomposition in a Composition-Local Library. This makes the subcomposition appear in the Node Library only when DisplayRotatingHemispheres.vuo (or another composition in the same folder) is open. If you want the subcomposition to appear in the Node Library for all compositions, click on the subcomposition window and go to File > Move to User Library. (For an explanation of Composition-Local and User Library folders, see Installing a node.)

Reasons to use subcompositions

The Make Hemisphere subcomposition illustrated one motivation for using subcompositions: to avoid recreating the same composition pieces over and over again. A subcomposition enables you to assemble a composition piece once and reuse it many times. If you notice a problem with the subcomposition or want to improve it, you only have to make the change in one place to have it apply everywhere the subcomposition is used.

Another reason you may want to use subcompositions is to better organize large compositions to make them more readable. You can replace a complex network of nodes and cables with a subcomposition that has a descriptive title and a clearly defined set of inputs and outputs.

A third reason for using subcompositions is to share your work with others in a modular format. When you create a composition piece that other people might like to use inside of their compositions, you can package it as a subcomposition that others can install in their Node Libraries.