Saturday, March 21, 2020

Mesh Fitting Without Spurious Smoothing

Update April 20, 2020: 

The latest versions of the export script automatically turns off High Resolution before exporting the vertex data, and then turns it back on. The procedure described below is thus unnecessary.

Original post:


As explained in http://diffeomorphic.blogspot.com/p/export-from-daz-studio.html, the Daz importer needs a json file exported from Daz Studio in order to do mesh fitting correctly. The json file contains the vertex coordinates with all morphs applied. The final world space coordinates depend on a combination of shapekeys, poses, and morph transfer to clothes, and it simply turned out to be too difficult to extract this information from the duf files themselves. In contrast, finding the coordinates with a Daz Studio script was quite easy, since the Daz scripting API has a function that accesses the cached geometry directly.

However, Alessandro Padovani discovered a problem with this: the cached geometry depends not only on the morphs but on mesh smoothing as well, see https://bitbucket.org/Diffeomorphic/import-daz/issues/30/major-subdivision-bug. This leads to some issues, e.g. in the teeth and eyes areas. To avoid this issue all characters must be at base resolution when exported from Daz Studio, even if the duf file is saved at high resolution.

The problem can be explained with a subdivided plane consisting of four square faces. In Daz Studio, the mesh looks like this:
Plane in Daz Studio, at subd level = 2
If we now save the duf file, export the json file with the vertex coordinates (Export Basic Data), and import the file into Blender, the plane is much rounder than in Daz Studio. This is the case even if the subsurf modifier is disabled.
Plane in Blender, without and with subsurf modifier
The reason is that the mesh at high resolution is smoothed even if the subdivision level is set to zero.
Plane in Daz Studio, at Subd level = 0



To fix this we must set the Resolution Level to Base before exporting the json file. We now have the plane without the undesired smoothing.
Plane in Daz Studio, at base resolution. The subd level is irrelevant.
The mesh now comes in correctly into Blender, with the same subdivision levels as in Daz Studio.
Plane in Blender, without and with subsurf modifier

 

To summarize: to make meshes look the same in Blender and Daz Studio, save the scene at high resolution but export the json file at base resolution.


A scene often consists of several characters with clothes and hair. To quickly change the resolution of all meshes:
  1. Select all objects in the Scene tab.
  2. Select all objects in the Parameters tab.
  3. Search for resolution in the search box. 
  4. Change the Resolution Level to Base.