Wednesday, May 25, 2022

Geometry Nodes and Geografts

In the previous post we discussed how to use geometry nodes to add geoshells to a mesh. This time we will use geometry nodes to merge geografts. The new option to the Merge Geograft button is available in the development version and Blender 3.1. Also this setup was explained to me by Midnight Arrow.

The advantage with geometry nodes is that they are non-destructive. Once we have joined the geograft with the body mesh destructively, the vertex order has changed and we can no longer add new morphs. There is an option to add a vertex table which keeps track of the original vertex numbers, but that only works for shapekeys which don't intersect with the geograft, and no morphs can be added to the geograft. If we merge with geometry nodes on the other hand, the original meshes are still present, and we can add new morphs if we disable the nodes modifier.

Here is the geograft we want to merge: a tail.
Select the body and the tail and press Merge Geografts. Enable the new option Geometry Nodes (Experimental). Also disable Add Vertex Table, which is unnecessary since geometry nodes keep the original meshes intact.
The geograft is still present but it is hidden, both in the viewport and for rendering.
The body mesh acquires a new nodes modifier. It takes three inputs: the edge vertex group which specifies the vertices to merge, the mask vertex group which contains the vertices to delete, and the merge distance. The latter is set to 0.1 mm which should work in most cases. The distance should be decreased if there are vertices closer than that.
Here are the edge and mask vertex groups.
And here is the node tree.
Here is the tail geograft, before and after it has been merged to the body.

To add a new shapekey, disable the nodes modifier in the viewport and unhide the geograft mesh. We can now add morphs and other shapekeys as usual. Once the morphs have been loaded, the modifier is enabled again.

Here we added a shapekey to the tail in this way.

Merging with geometry nodes is rather expensive. We can speed up viewport performance by disabling the nodes modifier while we build poses, and reenble it when it is time to render.

If we want to merge the geograft destructively, e.g. because we want to export the character to some other application, we can simply apply the nodes modifier. Unfortunately this only works if the mesh does not have any shapekeys.