Sidor

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.


Wednesday, May 18, 2022

Geometry Nodes and Shells

Geometry nodes is a powerful way to manipulate meshes that was introduced in Blender 3.1. They are used in the development version of the DAZ Importer as an alternative way to import geoshells and geografts from DAZ Studio. This could not have happened without the help of commenter Midnight Arrow, who explained to me about geometry nodes in general, and how they could be used in these specific cases.

This blog post describes how to import a geoshell as a geometry node setup in Blender. Later posts will cover geografts and how to import characters with shells and geografts directly from the DAZ database, without taking the detour over DAZ Studio.

Here we have a dirty character in DAZ Studio. The dirt is added with a geoshell called FX layer 01.
In the Parameters tab we find that the shell is pushed away from the main mesh by a small distance; Offset Distance = 0.0050 cm. There is also the list of surfaces affected by the shell.
By default a shell in DAZ Studio corresponds to a node group in the Blender materials. To generate a geometry node tree instead, we change the global setting Shell Method to Geometry Nodes (Experimental).
The body mesh looks strange in the viewport. This is because the shell becomes a second mesh which is located in almost the same place as the body mesh.
The shell by itself is an empty mesh, i.e. it does not have any vertices, edges or faces. But it has materials and a nodes modifier which generates the mesh. The modifer has a number of parameters:
  • Figure: The mesh that the shell copies.
  • Shell Offset: This is the Offset Distance parameter in DAZ Studio. In this case it is 0.005 cm = 0.00005 m.
  • Material slots: There is an entry for each material where the shell is visible and not totally transparent.

We can inspect the node tree in the geometry node editor. The nodes modifier generates a new mesh where the body materials are replaced by the shell materials.

Here is the shell mesh by itself, with viewport shading set to sold and rendered, respectively.

Here is a rendered example, with the two different Shell Method settings.
 
There is a problem with previewing the shell materials. Geometry nodes require that the materials pick up the UV maps with named UV Set or Attribute nodes, but Blender 's previewer only works if we use a Texture Coordinate node for that.
Here is how one of the shell materials is previewed. Since it uses a Attribute node, the previewer doesn't find the UV coordinates but uses the value of the first pixel at (0,0).
Fortunately, we can use the new Make Palette tool to preview the shell materials. This tool was originally intended for storing materials for the new asset browser, but it can also be used for previewing. Select the shell in the outliner and make a palette.
Here is the palette viewed from above, in solid and rendered viewport shading. The shell mesh has nine materials, but there are only eight material slots in the nodes modifier. This is because the Irises material (material number 8) is visible but purely transparent.