Presets
April 13, 2026 · View on GitHub
Source: src/mpfb/ui/presets/enhancedsettings/
Parent panel: MPFB_PT_Presets_Panel ("Manage save files")
Overview
The "Skin material save files" panel saves and loads the shader parameters of the Enhanced Skin material. The Enhanced Skin material is a procedural node-based material where the actual colour, roughness, subsurface scattering, and similar visual properties are controlled by input socket values on a central ShaderNodeGroup. This panel serialises those socket values to a JSON file so they can be reapplied later — to the same character or to a different one.
Save files use the naming convention enhanced_settings.{name}.json and are stored in the user config directory. A built-in default settings file (enhanced_settings.default.json) is copied into that directory the first time the panel is initialised, so there is always at least one preset available.
Three workflows are offered:
- Apply — select an existing settings file from the dropdown and apply its values to the current character's skin material.
- Overwrite — replace an existing settings file with the current skin material's values.
- Save new — type a name and create a new settings file.
The panel requires the active object to be a basemesh, a body proxy, or a skeleton (poll strategy: BASEMESH_OR_BODY_PROXY_OR_SKELETON_ACTIVE).
Panel
MPFB_PT_Enhanced_Settings_Panel ("Skin material save files")
| Attribute | Value |
|---|---|
bl_label | "Skin material save files" |
bl_category | MATERIALSCATEGORY |
bl_parent_id | MPFB_PT_Presets_Panel |
bl_options | {'DEFAULT_CLOSED'} |
| Base class | Abstract_Panel |
| Poll | BASEMESH_OR_BODY_PROXY_OR_SKELETON_ACTIVE |
The panel draws:
available_settings— a dropdown listing allenhanced_settings.*.jsonfiles found in the user config directory (populated byUiService.get_enhanced_settings_panel_list()).- Apply selected presets button — loads the selected settings file and applies its values to the skin material.
- Overwrite settings button — overwrites the selected settings file with the current material state.
name— a text field for entering the name of a new settings file.- Save new settings button — creates a new settings file using the name from the text field.
On first use, if no enhanced_settings.default.json exists in the user config directory, the panel copies the built-in default template into place so the dropdown is never empty.
Operators
MPFB_OT_ApplyEnhancedSettingsOperator
| Attribute | Value |
|---|---|
bl_idname | mpfb.enhancedsettings_apply_settings |
bl_label | "Apply selected presets" |
bl_options | {'REGISTER'} |
| Poll | Custom: active object must exist and available_settings must have a value |
Loads a saved settings file and applies its socket values to the skin material on the character. Steps:
- Validates that the active object exists.
- Reads the selected settings name from the
available_settingsscene property. - Loads the JSON file at
{user_config}/enhanced_settings.{name}.json. - Resolves the basemesh or body proxy from the active object.
- Iterates the material slots on the basemesh, searching for a
ShaderNodeGroupnode whose sockets includecolorMixIn(the marker that identifies the Enhanced Skin material node group). - Calls
NodeService.set_socket_default_values()to write each saved value back to the node group's input sockets.
Reports ERROR if the object, basemesh, or settings file cannot be found; reports INFO on success.
MPFB_OT_OverwriteEnhancedSettingsOperator
| Attribute | Value |
|---|---|
bl_idname | mpfb.overwrite_enhanced_settings |
bl_label | "Overwrite settings" |
bl_options | {'REGISTER'} |
| Poll | ANY_OBJECT_ACTIVE |
Overwrites an existing enhanced settings file with the current skin material state. Steps:
- Validates that the active object exists.
- Reads the selected settings name from the
available_settingsscene property. - Validates that the settings name is not empty.
- Delegates to the shared
_save_material()helper (see below).
MPFB_OT_SaveNewEnhancedSettingsOperator
| Attribute | Value |
|---|---|
bl_idname | mpfb.save_new_enhanced_settings |
bl_label | "Save new settings" |
bl_options | {'REGISTER'} |
| Poll | ANY_OBJECT_ACTIVE |
Saves the current skin material state as a new settings file. Steps:
- Validates that the active object exists.
- Reads the desired name from the
namescene property (the text field). - Validates that the name is not empty and contains no spaces.
- Validates that
{user_config}/enhanced_settings.{name}.jsondoes not already exist. - Delegates to the shared
_save_material()helper (see below).
Reports ERROR for any validation failure.
Shared helper: _save_material() (operators/_savematerial.py)
Both Overwrite and Save New delegate material serialisation to this module-level function. It:
- Resolves the basemesh or body proxy from the active object.
- Validates that the basemesh has a material.
- Iterates the material slots on the basemesh, searching for a
ShaderNodeGroupnode whose sockets includecolorMixIn. - Records the name of the material (stripping any prefix or suffix separated by
".") and the default values of all input sockets on the matching node group. - Writes a JSON file at
{user_config}/enhanced_settings.{name}.jsoncontaining a dictionary keyed by material name. - Calls
UiService.rebuild_enhanced_settings_panel_list()to refresh the dropdown in the panel.
Properties
Scene properties (prefix "EnS_", sourced from enhancedsettings/properties/)
| Property | Type | Default | Description |
|---|---|---|---|
name | string | "" | The name to use when saving a new settings file. Must not be empty or contain spaces, and must not match an existing settings file. |
Dynamic properties (defined in code)
| Property | Type | Description |
|---|---|---|
available_settings | enum (dynamic) | Lists all enhanced_settings.*.json files found in the user config directory, populated at panel draw time by UiService.get_enhanced_settings_panel_list(). |
Related
- NodeService — reading and writing shader node socket values
- UiService — manages the cached list of available settings files
- Presets index — overview of the full Presets section