Sunday, January 26, 2025

Custom Properties Cleanup

The DAZ Importer creates lots of custom properties when a character is imported. These properties contain information from the duf file which is necessary for the proper function of other tools.

The add-on does not only create lots of object properties, but custom properties for meshes, materials, bones and posebones as well.

However, spamming the area with lots of custom properties is considered impolite and is frown upon. Other add-ons such as Rigify or MMD tools create a single custom property which contains all the needed information in a complex data structure.
Rigify only creates one object property and one armature property.

 
In the last commit the custom properties have been redesigned, and now the DAZ Importer also adds a single custom property. This probably comes with a small performance penalty, because accessing the data of a complex property takes more time than accessing simple properties. However, this effect should be neglible.

Care has been taken to make this change backward compatible, so old files should still work without modification. However, it is not forward compatible, so figures imported with the latest version will not work propertly in older versions of the DAZ Importer.

The Utilities panel has a new subpanel, called DAZ Importer Properties, where the components of the custom properties can be inspected. This is mainly for debugging purposes. The listing also indicates whether objects use the modern, single, complex property, and the legacy multiple, simple properties.
However, there are some situations where simple properties are still needed. One is if the figure should work correctly even if the DAZ Importer add-on is disabled or not even installed. A typical situation is if we make an animation with Simple IK and FK-IK switching. The animation should still work properly if the file is sent to a render farm which has not installed the DAZ Importer. This will work because the Simple IK properties are simple properties.

The MHX rig does not work by default if the MHX runtime system is disabled. The reason is that MHX uses RNA properties rather than ID properties, for reasons explained here. To make it work at a render farm the file properties.py  in the runtime folder must be saved with the blend file, in the same way as the file morph_armature.py must be loaded to make morping armatures work without the DAZ Importer. This is inconvenient and I intend to replace MHX RNA properties by ID properties in the future.

Finally, there is an important type of custom properties that must be simple propertes: morphs. In Blender morphs are implemented as object and armature properties that drive bone rotations, shapekeys and other properties. Morph properties can not be part of a single, complex property. That would slow down the evaluation of morphs, which already can take excessive time if many morphs are loaded. Even more importantly, it wouldn't work at all, because the morphs might evaluated in the wrong order. 

Morph properties are connected with a complex web of drivers, and it is crucial that the morphs are evaluated in the right order. This is guaranteed if the morph properties are simple properties.. There would be no such guarantee if they were parts of a complex property, and in fact that is not always the case. Besides, the morphs should work if the DAZ Importer is not enabled, otherwise we would end up with ugly faces.

So unfortunately the add-on is still flooding the custom properties if a figure has many morphs. I don't see any way around that.

Sunday, January 12, 2025

Viewport Performance

DAZ meshes can be quite heavy and can slow down the viewport. Genesis 9 is worse than older generations, but clothes and especially hair can have a much higher poly-count. Add subdivisions, hair, drivers, etc. and viewport performance could become much worse.

Here are some suggestions for improving viewport performance. The suggestions are discussed in more detail below.

  • Use solid view instead of rendered view.
  • Turn on simplify and set max viewport subdivisions to zero.
  • Disable drivers when when you pose, enable them when you work with morphs. The plugin can easily create hundreds of drivers that take a lot of time to update (Morphs > Disable Drivers).
  • Add shapekey mute drivers to disable shapekeys with zero value.
  • Put heavy meshes in separate collections that can be excluded during posing. Hair can be especially heavy.
  • Put objects that are not in view in separate collections.
  • Finalize meshes and armature in the Finishing panel. This removes some data that is needed for adding morphs etc., but improves viewport performance.
  • Add a mannequin to block the animation. This a collection of meshes that are bone parented, which performs much better than a mesh with vertex groups.

This post will be updated include other optimization techniques.


Solid view instead of rendered view

This is sort of obvious. Even textured mode is more costly than material mode.

Simplify

The Simplify tab contains Blender's native tools for improving viewport speed. Usually we don't need to see subdivisions in the viewport. There is a global setting that limits the number of subdivision levels when DAZ scenes are imported, both the viewport and render levels.

 
The texture limit speeds up rendered view. However, the large textures may still take a lot of time to load, because Blender has to load the full texture before it can apply limitations. The Resize Textures tool permanently replaces textures with lower-resolution ones. Note that textures must be saved locally before they can be resized.

 

Disable drivers

Morphs are implemented in Blender as a complex web of drivers that control bone rotations and locations, mesh shapekeys, and custom properties. A DAZ figure with the standard morphs loaded can easily have many hundreds of drivers, and the evaluation of many drivers takes significant time.
The Disable Drivers button at the top of the Morphs panel disables all morph drivers, thus eliminating the need to compute the drivers. Shapekeys are also muted.
When the drivers are disabled the morphs do not function, and the Morphs panel only contains a button to Enable Drivers again

 

Shapekey mute drivers

DAZ figures often have many shapekeys, e.g. for JCMs and FACS morphs. The evaluation of those shapekeys takes time, but it is unnecessary to include zero shapekeys in the process.

The global option "Shapekey Mute Drivers" adds drivers to the shapekey enable channel, muting the shapekey if it is zero (within rounding errors). Muted shapekeys are not included in the evaluation of the final vertex locations which should lead to a performance gain.

When "Optimize JCM Drivers" is enabled some drivers related to JCMs are eliminated.

 

Separate collections for different meshes

Hair and clothes are often heavier than the figure itself, but are not really necessary when posing. We can put such objects into subcollections that are disabled during posing and only enabled again when it is time for rendering.

Here is Aiko with hair and clothes. Hair and clothes have been put into separate collections.
Here the hair and clothes collections are disabled. This does not really hamper posing.

 

Finalize meshes and optimize drivers 

The Finishing panel contains some buttons that can improve performance. However, this should be done as a final step when the figure setup is finished.

  • Finalize Meshes: Removes internal properties from meshes, needed e.g. to merge geografts.
  • Optimize Drivers: Optimize the web of drivers. New morphs can not be loaded afterwards. 

The Final Optimizations option in Easy Import tool does the same thing.

 

Mannequins

A mannequin is a collection of meshes that are parented to the bones of the armature. This improves performance because bone parenting can be evaluated much faster than the influence of multiple vertex groups. Mannequins are useful for blocking out an animation, even if final tweaking with the real mesh may be necessary. The DAZ Importer can create a mannequin for a selected set of meshes.

To create a mannequin, select the meshes and press "Add Mannequin". This tool requires that the Object Tools feature is enabled.
The original meshes are put into a subcollection called "Meshes", and the mannequin meshes belong to the new "Mannequin" collection. We can now pose the figure with the mannequin enabled, and switch to the original meshes for final tweaking and rendering

 

Saturday, January 4, 2025

FILATOON

With daz studio 4.23 comes Filatoon, a new shader to draw toon style figures. With blender 4.3 and the new 4.3 version of the importer we can now get filatoon figures in blender. Beweare this is a first release so not all the filatoon features are supported, but it is enough to import most toon figures available in the DAZ shop.

ref. https://bitbucket.org/Diffeomorphic/import_daz/issues/2235/

Note that filatoon can only be rendered with eevee, not with cycles, this is the same in daz studio where filatoon only works with filament and not with iray. The toon outline is rendered with freestyle.

However there's a difference in lighting between daz studio and blender, as toon figures in daz studio are not lit by the HDRI, while in blender they always are. Even with the new light linking in blender 4.3 there's no way to exclude the HDRI. Of course this is not a issue if we only use regular lights without HDRI.

Below there's an example where we import a scene with HDRI, we have the G8F figure with iray materials, and the G9F toon with filatoon materials. We can see that in daz studio iray can't correctly render the toon figure, while filament can't correctly render the G8 figure. In blender we can render with eevee and both the toon and G8 figures are rendered correctly, however both are affected by the HDRI.


We can adjust both the HDRI threshold and the toon light inside the "daz toon diffuse" and "daz toon light" groups, note that adjusting one group will affect the whole scene.



update. OUTLINE MODE. Due to some user requests Thomas implemented different outline methods, or not importing the outline at all. The option is in the global settings.

The viewport in solid mode needs the backface culling for solidify to work, this is done automatically by the addon if "render settings" is set to "update" in the global settings. Note that solid mode can't correctly render filatoon anyway.

The viewport in material preview or rendering using eevee works fine and that's what the filatoon shaders are for.

  • None: don't import the daz outline.
  • Freestyle: use freestyle, visible only in rendering not in the viewport.
  • Line Art: use the grease pencil, visible in the camera view and rendering.
  • Solidify: use the solidify modifier, visible in the viewport and rendering.



Thursday, January 2, 2025

Strand-Based Hair and Hair Guides

In DAZ Studio we can give characters Strand-Based Hair (SBH), which corresponds to hair curves in Blender. Unfortunately, SBH often has a very high vertex count, which makes it rather unusable unless you have lots of patience. However, the DAZ Importer has an option to import hair guides in addition to the SBH itself, and the guides are much more lightweight and therefore better suited for Blender hair.

Here is Aiko equipped with a new hairdo made from SBH.
We can inspect the vertex counts with the mesh statistics tool. Aiko herself has some 16,500 verts, but the hair has a whopping 2,5 million verts, which will make it very heavy to animate.
Exporting a dbz file to Blender takes almost 70 seconds, compared to between 5 and 10 seconds for a typical transmapped hair. Waiting for the export script to conclude is quite painful, but there is nothing to do about this.
In Blender, turn on the "Import All Hair Versions" option. This will import the hair guides in addition to the hair itself.
Two polyline hair meshes are imported into Blender: the main hair with 2,5 million verts, and the hair guides with 200,000 verts. A difference of a factor around 12.
Now we delete the main hair and convert the hair guides to hair curves. 200,000 verts is still somewhat high for my taste, but the result with ten render children is quite good, so there would be nothing to gain by keeping the full hair mesh.