Mhx2+ Exporter/Importer
Posted: Mon Oct 15, 2018 8:26 pm
Well, I finally got my enhanced exporter working and supporting multiple materials per object!
The exporter plugin for MakeHuman is a modification of the standard mhx2 exporter that adds additional material data to the exported .mhx2 file. The addition to the .mhx2 file is ignored by the standard Blender .mhx2 importer. The additional materials are kept in a .mham file in the same directory as the .mhclo file. The file is in json format, the material is represented the same way materials are represented in the current .mhx2 export files. There is also a list of geometries which specify the material and the faces it applies to.
Of course for an exporter you need a matching importer and I have written a Blender importer addon that handles the additional information. It's a stripped down version of the standard addon that only handles importing a toon "as is" without all the transformations and runtime support in the standard importer-runtime addon. It will also make use of the Principled shader in recent versions of Blender where they are available. And of course it includes the bug fixes I've previously posted for the standard importer.
The final piece of the puzzle, which I haven't written/adapted yet is an addon for Blender that writes out a .mham file for an object. Hopefully I can use the code in MakeHuman as a starting point. I'm also going to look at saving the material nodes more directly since they won't go through MH anyway.
Anyway, I'm now at the point where I can add materials to objects and have them handled automatically every time I export them to Blender, without my having to do anything manually after importing them.
If there's any interest I'll make them available after I clean them up a bit.
Sample .mham file:
The exporter plugin for MakeHuman is a modification of the standard mhx2 exporter that adds additional material data to the exported .mhx2 file. The addition to the .mhx2 file is ignored by the standard Blender .mhx2 importer. The additional materials are kept in a .mham file in the same directory as the .mhclo file. The file is in json format, the material is represented the same way materials are represented in the current .mhx2 export files. There is also a list of geometries which specify the material and the faces it applies to.
Of course for an exporter you need a matching importer and I have written a Blender importer addon that handles the additional information. It's a stripped down version of the standard addon that only handles importing a toon "as is" without all the transformations and runtime support in the standard importer-runtime addon. It will also make use of the Principled shader in recent versions of Blender where they are available. And of course it includes the bug fixes I've previously posted for the standard importer.
The final piece of the puzzle, which I haven't written/adapted yet is an addon for Blender that writes out a .mham file for an object. Hopefully I can use the code in MakeHuman as a starting point. I'm also going to look at saving the material nodes more directly since they won't go through MH anyway.
Anyway, I'm now at the point where I can add materials to objects and have them handled automatically every time I export them to Blender, without my having to do anything manually after importing them.
If there's any interest I'll make them available after I clean them up a bit.
Sample .mham file:
- Code: Select all
{
"mhx2_version" : "0.30",
"materials" : [
{
"name" : "High_poly4glass",
"diffuse_color" : [0.64,0.64,0.64],
"diffuse_map_intensity" : 1,
"specular_color" : [0.5,0.5,0.5],
"specular_map_intensity" : 1,
"shininess" : 1,
"opacity" : 0,
"translucency" : 0,
"emissive_color" : [0,0,0],
"ambient_color" : [1,1,1],
"transparency_map_intensity" : 1,
"shadeless" : false,
"wireframe" : false,
"transparent" : true,
"alphaToCoverage" : true,
"backfaceCull" : true,
"depthless" : false,
"castShadows" : true,
"receiveShadows" : true,
"sssEnabled" : false,
"sssRScale" : 0,
"sssGScale" : 0,
"sssBScale" : 0,
"diffuse_texture" : "textures/brown_eye.png",
"specular_map_texture" : "textures/EyeballSpecular.png"
}
],
"geometries" : [
{
"auxmaterials" : [
{
"material" : "High_poly4glass",
"faces" : [
0,1,2,3,4,5,6,7,8,9,
10,11,12,13,14,15,16,17,18,19,
20,21,22,23,24,25,26,27,28,29,
30,31,32,33,34,35,36,37,38,39,
40,41,42,43,44,45,46,47,48,49,
50,51,52,53,54,55,56,57,58,59,
60,61,62,63,64,65,66,67,68,69,
70,71,72,73,74,75,76,77,78,79,
80,81,82,83,84,
350,351,352,353,354,355,356,357,358,359,
360,361,362,363,364,365,366,367,368,369,
370,371,372,373,374,375,376,377,378,379,
380,381,382,383,384,385,386,387,388,389,
390,391,392,393,394,395,396,397,398,399,
400,401,402,403,404,405,406,407,408,409,
410,411,412,413,414,415,416,417,418,419,
420,421,422,423,424,425,426,427,428,429,
430,431,432,433,434
]
}
]
}
]
}