MPFB (MakeHuman Plugin For Blender)

repository·master·Indexed 20 days ago

https://github.com/makehumancommunity/mpfb2

A free and open source human generator designed for Blender (version 4.2 or higher). MPFB allows users to create human characters within the Blender ecosystem and provides a structured architecture consisting of Services, Entities, UI, and Data layers. The documentation covers getting started guides, code architecture for developers, custom operator and panel creation using MpfbOperator and Abstract_Panel, and the handling of MHCLO clothing files.

Tokens
177.1K
Snippets
421
Records
764
Agent score
68%

What's inside MPFB

  1. Overview of NodeService

    master

    NodeService is a collection of static methods used to manage and manipulate Blender shader node trees and nodes within MPFB. It serves as the primary interface for all shader-related operations, including node creation, destruction, querying, and link management.

    Key Capabilities:

    • Node Tree Lifecycle: Creating, destroying, and clearing node trees.
    • Node Creation: Generic and type-specific methods for adding nodes.
    • Node Queries: Finding nodes by name, type, or class.
    • Socket Operations: Finding sockets and getting/setting default values.
    • Link Management: Creating and removing connections between nodes.
    • Bulk Operations: Applying entire node tree configurations from dictionary definitions.
    • Custom Node Groups: Managing MPFB's composite shader node groups.

    Serialization Formats:

    • v1 (Legacy): Older serialization format.
    • v2 (Current): Robust format providing complete node information, including socket identifiers and attribute metadata, ensuring compatibility across Blender versions.

    Note: All methods in NodeService are static; do not attempt to instantiate the class.

  2. Overview of MaterialService

    master

    The MaterialService is a static service responsible for the lifecycle and management of materials assigned to Blender objects within MPFB. It handles creation, identification, modification, and management of various material types.

    Supported Material Types:

    • MakeSkin: The standard MakeHuman material format.
    • enhanced skin: Procedural skin featuring pore detail.
    • layered skin: Procedural skin with color control groups.
    • procedural eyes: Specialized procedural eye materials.
    • game engine: Simple materials using a Principled BSDF node.

    Key Capabilities:

    • Lifecycle Management: Creating empty or skin-specific materials, assigning them to objects, and managing per-body-part material slots.
    • Ink Layer Management: Managing stacked texture overlays (ink layers) for makeup, tattoos, and decorations on MakeSkin and layered skin materials.
    • I/O: Loading and saving materials from .blend files.
    • Color Management: Providing static viewport diffuse colors and a color adjustment system for applying tints.

    Note: All methods in MaterialService are static; do not attempt to instantiate the class.

  3. Explore MPFB2 Developer UI components

    master

    The MPFB2 developer interface is composed of specialized panels and operators designed for debugging and system inspection. Key components include:

    • Developer Panel (MPFB_PT_Developer_Panel): The primary interface for developer-centric tasks.
    • Node Developer Panel (MPFB_PT_Node_Developer_Panel): A specialized panel for inspecting and developing nodes.
    • Log Level Operators: Tools to manage the verbosity of system logs, including setting specific levels, resetting to defaults, and listing available levels.
  4. Use the Material panel for mesh modifications

    master

    The Material panel (found within the Operations panel) provides tools for modifying materials on MPFB character meshes. It is available for any recognized MakeHuman object that is not a skeleton (armature), such as the basemesh, body proxy meshes, and clothing items.

    The panel is organized into three sections:

    • Makeup: Contains the Remove makeup button.
    • Adjust material: Contains the Set normalmap button.
    • Experimental: Contains toggles for recreate_groups and reuse_textures, and the Create v2 skin button.
  5. Use MakeSkinMaterial for MHMAT workflows

    master

    MakeSkinMaterial is a specialized class that extends MhMaterial to bridge the MHMAT file format with Blender's node-based material system. It is designed specifically for the MakeSkin workflow.

    Workflow Directions

    1. Import (MHMAT → Blender)

    Use apply_node_tree to load a makeskin.json node-tree template. The method automatically substitutes $variable placeholders (like texture paths and color values) from the MHMAT settings into the template and applies it to a Blender material via NodeService.

    2. Export (Blender → MHMAT)

    Use populate_from_object to scan an existing Blender object's node tree (including texture nodes and Principled BSDF values) to populate the material's settings. Once populated, use export_to_disk to serialize the data into an .mhmat file. You can optionally normalize textures by copying and renaming them to match the MHMAT base name.

    import bpy
    from mpfb.entities.material.makeskinmaterial import MakeSkinMaterial
    
    # Import Example
    mat = MakeSkinMaterial()
    mat.populate_from_mhmat("/path/to/skin.mhmat")
    
    blender_material = bpy.data.materials.new(name="SkinMaterial")
    blender_material.use_nodes = True
    mat.apply_node_tree(blender_material)
    
    # Export Example
    obj = bpy.context.active_object
    mat = MakeSkinMaterial()
    mat.populate_from_object(obj)
    
    error = mat.check_that_all_textures_are_saved(
        obj,
        mhmat_dir="/path/to/output",
        mhmat_bn="myshirt"
    )
    if error:
        print("Problem:", error)
    else:
        mat.export_to_disk("/path/to/output/myshirt.mhmat")
  6. Manage vertex weights with MakeWeight

    master

    MakeWeight is a tool for managing vertex weight files independently of specific rig-attachment workflows. In the MakeHuman ecosystem, vertex weights define how much each bone of a skeleton influences each vertex of a base mesh. These weights are stored as JSON files.

    Key Capabilities:

    • Import: Load a weight JSON file onto the active mesh to restore vertex groups.
    • Export: Save current vertex groups as a weight JSON file for redistribution.
    • Truncate: Clean up noisy weight paint data by clamping small values to zero in a selected vertex group.
    • Symmetrize: Mirror weight values between the +X and -X sides of the mesh.

    Availability: The MakeWeight panel is only visible when the active object is a basemesh, a skeleton, or an object whose nearest relative in the scene hierarchy is a skeleton.

  7. Use MakeRig to author custom rig definitions

    master

    MakeRig is a specialized toolset for rig authors to create, modify, and manage custom rig definition files (JSON) and their accompanying vertex weight files. Unlike the standard rigging workflow which applies existing rigs, MakeRig allows for the creation of new rig structures from scratch.

    All MakeRig tools are located in the RIGCATEGORY sidebar tab under the parent panel MPFB_PT_Create_Panel ("Create assets").

  8. Understand the MPFB2 License (GNU GPL v3)

    master

    MPFB2 is licensed under the GNU General Public License version 3 (GPLv3). This is a strong copyleft license that ensures the software remains free for all users.

    Key implications for developers:

    • Freedom to Run and Modify: You have unlimited permission to run and modify the unmodified program.
    • Copyleft Requirement: If you convey a modified version of the program, you must license the entire work as a whole under the GPLv3.
    • Source Code Availability: If you distribute the software in object code form (e.g., a compiled binary), you must also provide the Corresponding Source (the preferred form for making modifications, including scripts to control installation and execution).
    • No Additional Restrictions: You may not impose further restrictions on the exercise of the rights granted by the license (e.g., you cannot charge license fees or royalties for the right to use the software).
    • Patent Grant: Contributors grant you a non-exclusive, worldwide, royalty-free patent license for their essential patent claims required to run/modify their contribution.
  9. Explore the New Human character creation workflows

    master

    The New Human section provides four specialized sub-panels for different character generation methods:

    • From scratch / From save file (newhuman/): Create a character directly in Blender using a fresh basemesh with optional phenotype shape keys, or load a previously saved MPFB character preset or a MakeHuman .mhm file.
    • Random human (randomize/): Generate a character with a randomized phenotype.
    • From MakeHuman (importer/): Import a character live from a running MakeHuman desktop application using a socket connection.
    • Importer Presets (importerpresets/): Manage and use named presets that store configuration settings for the 'From MakeHuman' socket import workflow.
  10. Use AnimationService for Blender animations

    master

    The AnimationService provides a collection of static methods for working with animations and poses in Blender. It handles the full lifecycle of animation data, including importing BVH motion capture files, analyzing and manipulating keyframes, making animations cyclic, and serializing/deserializing animation data to and from dictionaries.

    Warning: The animation functionality is currently experimental and not considered stable. It is primarily recommended for BVH import tasks unless you are specifically developing new animation functionality.

  11. Use FaceService to manage facial expressions and targets

    master
    The FaceService provides the public API for loading facial shape keys (targets) onto a basemesh and managing the expression stack. It handles loading Microsoft visemes, meta visemes, and ARKit face units, as well as reading, writing, and applying expression states via JSON files.