fredag 27 april 2018

Stable version 1.3

Finally, stable version 1.3 has been released.


Changes from previous version:

The add-on was developed on Windows 7. It has not been tested on Mac because I don't have access to any, but it does work under Linux. Hence earlier Mac problems due to case-sensitive file names should be solved.

söndag 15 april 2018


DAZ Studio is available for PC and Mac, but since I don't have access to any Mac the code has only been tested under Windows; more precisely, Windows 7. From user comments I have understood that there are problems to run the DAZ Importer under Mac, mainly because file paths are case-sensitive on Mac (?) but not on Windows.

As I said, I have no Mac to test on, but I do have a dual-boot machine with Windows and Linux. Linux is not really an interesting os for the DAZ importer, since DAZ Studio is not available on it, but it provides a testing ground for what happens with  a case-sensitive file system. In fact, somebody provided code for fixing problems with case sensitivity long ago (apologies for forgetting who), but the patch caused some obscure problems on Windows so I disabled it.

In the most recent unstable versions, the patch has been reinstated and I have managed to import DAZ files from my Windows hard drive under Linux. On Linux, it is crucial that the option Case-Sensitive Paths is enabled; it is found in the General section of the Settings panel. This option should be automatically enabled on Linux and Mac, and disabled on Windows, but because of some earlier confusion the default settings were switched. This bug is now corrected, but make sure that the settings are as in the figure below:

Here the same character has been imported and rendered under Windows and Linux. The lighting conditions and Blender versions are also different (2.79a vs 2.78), but the conclusion is that the add-on now works under Linux, at least for many characters.

Since the DAZ Importer seems to work under both Windows and Linux, it will hopefully work on Mac as well.

fredag 6 april 2018

Custom driver functions

In Genesis 3 and 8 characters, facial expressions are implemented as poses of the face rig. To be able to easily set a face pose, the expressions are driven by rig properties displayed in the Daz Runtime tab in the T panel. E.g., the bone lUpperMiddle may be driven by a scripted expression like


where A-j are driver variables, one for each rig property. In this case the data path of the A variable is ["DzVEE"], so A is the value of the rig property DzVEE, corresponding to the viseme EE. The problem is that in Blender the length of scripted expression is limited to 256 characters. If we load many face units, expressions and visemes, this limit is easily exceeded.

To circumvent this problem, about a year ago I introduced handlers, which are functions that are called every time the scene is updated. Instead of directly driving the bone locations by rig properties, the rig properties drive a number of intermediate bone properties, and the bone locations are then updated by the handlers. The advantage of this method is that each intermediate property is only driven by part of the original rig properties, so the length of the scripted expressions can be kept under the 256 character limit.

However, handlers introduce new problems of their own. It does not seem possible to combine handlers with other drivers, because the handlers are not drivers. This becomes a problem e.g. for eyelids, which are driven both by the eye rotation and by face units such as Eye Close. But the most severe problem with handlers is that they slow down the viewport. All handlers are called each time a scene is updated, which is very time consuming.

Following a suggestion by Alec Vallintine I have introduced yet another way to drive bone locations: using custom driver functions. This method seems to solve all the problems with the previous two methods:
  1. There no limit to the number of driving properties.
  2. Driver functions can be combined with other drivers.
  3. Performance is much better than with handlers.
Since a few days ago, drivers for facial expressions are implemented using this new method.

fredag 30 mars 2018

Recent progress

The Load Pose button loads a pose from a file to the active character. However, it is not so simple as to just rotate bones with the rotations in the file, because bones in Blender are oriented differently from in Daz Studio. The reason is that for a Blender bone the local Y axis points in the bone direction, whereas nodes in Daz Studio can be oriented in any way.

For a long time I thought that I knew how to transfer Daz rotations to Blender, because my algorithm worked flawlessly for characters up to Genesis 3. Alas, when Genesis 8 came along last year, the algorithm did not work correctly. I don't know why it worked for Genesis 1-3, but I suspect that the bone axes coincide with the global coordinate system for those characters, and my old algorithm worked in that case.

Anyway, the algorithm has now been updated, and the picture above shows the difference. Clearly the new version agrees better with Daz Studio than the previous one.

Once we have the correct correspondence between Daz and Blender poses, it becomes possible to translate bone drivers. This is useful for corrective shapekeys, known as Joint Corrective Morphs or JCM's in Daz Studio. A JCM is typically driven by a single Euler angle in Daz Studio, but due to the different bone orientations this corresponds to a mix of all three Euler angles in Blender.

To easily load JCM's for a character, simply press the new Load Correctives button in the Morphs section. If you enable Show Correctives, a list of available correctives open up, and you can select which morphs to load. If the active character is of type Genesis 3 and 8, a long list of shapekeys are loaded, driven by bone rotations. Apparently there are no JCM's for the older character types.

This picture illustrates the difference. The difference is not huge, but corrective shapekeys make deformation better.

Corrective shapekeys make deformation better for the character mesh, but the clothes don't have any. This can be fixed by transferring the shapekeys from the human to her clothes. With the clothes selected and the character mesh active, press the Transfer Correctives button. The deformation clearly improves.

There are several buttons for morph transfer:
  • Transfer Correctives: Transfer shapekeys with bone drivers and their drivers.
  • Transfer Shapekeys Only: Transfer only shapekeys, don't make drivers.
  • Transfer Driven Shapekeys: Transfer shapekeys with property drivers and their drivers.
There are also some options that control how the morphs are transferred:
  • Use All Morphs: Transfer all shapekeys from the active mesh. The alternative is to only transfer the active shapekey.
  • Use JCM Files: Some vendors have made custom JCM files for their clothes. If such files are found, use them if this option is enabled.
  • Use Auto Transfer: If no custom JCM file is found, automatically transfer shapekeys. This is both slower and less good than with custom JCM files.
Everything is very new and may change without notice

lördag 2 december 2017

PBR shader

The DAZ Importer (development version) can now create Cycles materials using the Principled BSDF, also known as the PBR shader. Here the same car has been imported with Cycles with PBR, Cycles without PBR, and Blender Internal.

(Actually, lightning was made differently in BI. The Cycles renders were lit by an environment map, the BI render was lit by two lamps and composited upon the background.)

The PBR shader makes a huge difference for materials like metals and glass. For characters the improvement is not so clear compared to standard Cycles. Here is the default Genesis 3 Female imported in three ways.

And here is a Genesis 8 character. The PBR variant developed some nasty white spots, e.g. on the neck, which is clearly visible even after denoising. In both Cycles renders the shadow on her cheek is also very jagged. Probably it comes from the hair mesh.

To enable the PBR shader, select the Principled Shader option in the Materials And Textures section of the Settings panel. This is still quite unstable and the option may move in the near future, e.g. to the import options.

måndag 27 november 2017

Hair deformation with surface modifier

In the previous post hair was animated with bones. This works well if the hair only has few degrees of freedom, like a pony-tail. However, for long, loose hair it becomes very tedious to animate the hair by hand. It would be much simpler to do a cloth simulation, but we all know that this becomes extremely slow for high-poly meshes.

In version 2.79, Blender has a new Surface Deform modifier, which can be used to speed up hair simulation. I created a low-poly hair guide and made a cloth simulation for it. The simulation is fast because the guide is a low-poly mesh. The animation was then transferred to the high-poly hair mesh using the surface deform modifier. The modifier is a bit picky; it does not work if the guide mesh contains concave faces, and the hair tends to develop spikes unless the guide is very smooth. By splitting the faces to triangles and smoothing the mesh I managed to get rid of the most glaring problems.

Here is a video that shows my take on it.

lördag 25 november 2017


This blog has been in a dormant state for a while. There are several reasons for this, one of these was that I started to get tired of the DAZ Importer and on CG in general. However, for the last month or so I started to take up Blender again, learning about the many of the awesome new features, e.g. denoising, HDRI images, shadow planes, and the surface deform modifier. It is also time to actually do something with the DAZ Importer and not just implementing it.

The topic of today's post is something I call winders. Long and flexible objects, such as chains, ropes, whips, or ponytails, often have armatures consisting of many small bones, one for each link. Posing each individual link is tedious, and it is often difficult to get a smooth curve.

Enter winders. A winder is a single bone that stretches along the entire chain, and by rotating the winder you can easily pose all links in the chain in a smooth fashion. Under the hood, a winder is implemented by Copy Rotation constraints with offset enabled. This means that once you have posed the winder, the individual links can be posed on top of that. In fact, there are two examples of winders in the MHX rig: the long fingers that pose the three finger links, and the back bone that poses the entire spine.

 To illustrate the feature, here is a model of Lara Croft (I think). The rig has been converted to MHX and we see the hair bones on the Clothes layer. The ponytail and the hair strands at her forehead are suitable examples of chains to which we can add a winder.


With the first bone in the ponytail selected, press Add Winder in the Rigging section of the Advanced Setup panel.

A winder bone is created, and the bones in the ponytail chain gets some constraints. The entire ponytail can now be easily posed with the winder bone.

And here is a short video where the ponytail and hair strands have been animated with winders.