# v-sekai/godot-vrm architecture

> Architecture diagram of the GitHub repository v-sekai/godot-vrm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/v-sekai/godot-vrm
- Repository: https://github.com/v-sekai/godot-vrm

## Overview

##### Project type and purpose
- This is a Godot Engine addon composed of two plugins:
- VRM importer/exporter plugin (addons/vrm)
- MToon Shader plugin (addons/Godot-MToon-Shader)
- It extends the Godot Editor via GDScript and shader modules to import/export glTF/VRM 1.0 files and supply a full implementation of the MToon shader.

##### File structure
- Top-level “addons” folder contains two plugin roots:
- Godot-MToon-Shader/ – shader source (.gdshader) + Inspector script + plugin.cfg/gd
- vrm/ – importer scripts (.gd), VRM spec modules (.gd / .tres), plugin.cfg/gd, node constraints, spring bone logic
- project.godot / vrm_samples demonstrate runtime usage.
- plugin.cfg + plugin.gd in each addon register EditorImportPlugin classes and EditorInspectorPlugin classes.
- The importer pipeline lives under addons/vrm/import_*.gd and VRMC_*.gd modules.

##### README for additional insights
- Confirms full VRM 1.0 import/export, glTF extension support, supported VRM features (node constraints, spring bones, MToon materials).
- Advises usage steps: install into addons/, enable plugins in Project Settings.

##### Elements
- Clear labels: e.g., “EditorImportPlugin (addons/vrm/plugin.gd)”, “VRMC_node_constraint.gd”
- Plugin loading → import pipeline → scene graph
- Export pipeline → file system
- Plugins (rounded rectangles, e.g., blue for VRM, green for MToon)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Engine
    subgraph "Godot Engine Core" 
        direction TB
        PluginManager["Plugin Manager"]:::core
        SceneGraph["Scene Graph"]:::core
        Renderer["Renderer"]:::core
    end

    %% Plugins Loading
    EditorStartup["Editor Startup"]:::core -->|loads| PluginManager
    PluginManager -->|loads VRM Addon| VRMPlugin
    PluginManager -->|loads MToon Addon| MToonPlugin

    %% VRM Addon Entry
    subgraph "VRM Addon" 
        direction TB
        VRMPlugin["EditorImportPlugin\n(addons/vrm/plugin.gd)"]:::vrm
        VRMConfig["plugin.cfg"]:::vrm
    end
    click VRMPlugin "https://github.com/v-sekai/godot-vrm/blob/master/addons/vrm/plugin.gd"
    click VRMConfig "https://github.com/v-sekai/godot-vrm/blob/master/addons/vrm/plugin.cfg"

    %% VRM Import Pipeline
    subgraph "Import Pipeline" 
        direction TB
        FSWatcher["File System Watcher"]:::module
        GLTFParser["glTF Parser\n(import_vrm.gd)"]:::module
        MeshAttr["Mesh Attributes\n(importer_mesh_attributes.gd)"]:::module

        subgraph "VRMC Modules" 
            direction TB
            VRMC_vrm["VRMC_vrm.gd"]:::module
            VRMC_anim["VRMC_vrm_animation.gd"]:::module
            VRMC_node["VRMC_node_constraint.gd"]:::module
            VRMC_spring["VRMC_springBone.gd"]:::module
            VRMC_mtoon["VRMC_materials_mtoon.gd"]:::module
            VRMC_hdr["VRMC_materials_hdr_emissiveMultiplier.gd"]:::module
        end

        subgraph "Node Constraint Logic"
            direction TB
            BoneConstraint["bone_node_constraint.gd"]:::module
            BoneApplier["bone_node_constraint_applier.gd"]:::module
        end

        subgraph "Spring Bone Logic"
            direction TB
            SpringLogic["vrm_spring_bone_logic.gd"]:::module
            SpringNode["vrm_spring_bone.gd"]:::module
        end

        subgraph "Metadata & Options"
            direction TB
            VRMMeta["vrm_meta.gd"]:::module
            VRMOptions["vrm_options_post_import_plugin.gd"]:::module
        end

        subgraph "Core Utilities"
            direction TB
            VRMConstants["vrm_constants.gd"]:::module
            VRMExt["vrm_extension.gd"]:::module
            VRMSecondary["vrm_secondary.gd"]:::module
            VRMToplevel["vrm_toplevel.gd"]:::module
            VRMUtils["vrm_utils.gd"]:::module
        end

        Builder["Scene Builder"]:::module
    end

    %% Export Pipeline
    subgraph "Export Pipeline"
        direction TB
        Exporter["Export Pipeline"]:::module
    end

    %% MToon Addon
    subgraph "MToon Shader Addon"
        direction TB
        MToonPlugin["EditorInspectorPlugin\n(addons/Godot-MToon-Shader/plugin.gd)"]:::mtoon
        MToonConfig["plugin.cfg"]:::mtoon
        Inspector["inspector_mtoon.gd"]:::mtoon
        subgraph "Shader Sources"
            direction TB
            ShaderMain["mtoon.gdshader"]:::mtoon
            ShaderCommon["mtoon_common.gdshaderinc"]:::mtoon
            ShaderCull["mtoon_cull_off.gdshader"]:::mtoon
            ShaderCutout["mtoon_cutout.gdshader"]:::mtoon
            ShaderCutoffCull["mtoon_cutout_cull_off.gdshader"]:::mtoon
            ShaderOutline["mtoon_outline.gdshader"]:::mtoon
            ShaderOutlineCut["mtoon_outline_cutout.gdshader"]:::mtoon
            ShaderOutlineTrans["mtoon_outline_trans.gdshader"]:::mtoon
            ShaderOutlineZ["mtoon_outline_trans_zwrite.gdshader"]:::mtoon
            ShaderTrans["mtoon_trans.gdshader"]:::mtoon
            ShaderTransCull["mtoon_trans_cull_off.gdshader"]:::mtoon
            ShaderTransZ["mtoon_trans_zwrite.gdshader"]:::mtoon
            ShaderTransZCull["mtoon_trans_zwrite_cull_off.gdshader"]:::mtoon
        end
    end
    click MToonPlugin "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/plugin.gd"
    click MToonConfig "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/plugin.cfg"
    click Inspector "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/inspector_mtoon.gd"
    click ShaderMain "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon.gdshader"
    click ShaderCommon "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_common.gdshaderinc"
    click ShaderCull "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_cull_off.gdshader"
    click ShaderCutout "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_cutout.gdshader"
    click ShaderCutoffCull "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_cutout_cull_off.gdshader"
    click ShaderOutline "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_outline.gdshader"
    click ShaderOutlineCut "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_outline_cutout.gdshader"
    click ShaderOutlineTrans "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_outline_trans.gdshader"
    click ShaderOutlineZ "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_outline_trans_zwrite.gdshader"
    click ShaderTrans "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_trans.gdshader"
    click ShaderTransCull "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_trans_cull_off.gdshader"
    click ShaderTransZ "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_trans_zwrite.gdshader"
    click ShaderTransZCull "https://github.com/v-sekai/godot-vrm/blob/master/addons/Godot-MToon-Shader/mtoon_trans_zwrite_cull_off.gdshader"

    %% Data Stores
    Files[".vrm/.gltf Files"]:::data
    Samples["Sample Scenes"]:::data

    %% Sample Scenes
    subgraph "vrm_samples"
        direction TB
        SampleScene["sample_scene.tscn"]:::data
        LoadScene["load_at_runtime_scene.tscn"]:::data
        SampleScript["sample_script.gd"]:::data
        LoadScript["load_at_runtime_scene.gd"]:::data
    end
    click SampleScene "https://github.com/v-sekai/godot-vrm/blob/master/vrm_samples/sample_scene.tscn"
    click LoadScene "https://github.com/v-sekai/godot-vrm/blob/master/vrm_samples/load_at_runtime_scene.tscn"
    click SampleScript "https://github.com/v-sekai/godot-vrm/blob/master/vrm_samples/sample_script.gd"
    click LoadScript "https://github.com/v-sekai/godot-vrm/blob/master/vrm_samples/load_at_runtime_scene.gd"

    %% Flows
    FSWatcher --> GLTFParser --> MeshAttr --> VRMC_vrm --> VRMC_anim --> VRMC_node --> VRMC_spring --> VRMC_mtoon --> VRMC_hdr
    VRMC_node --> BoneConstraint --> BoneApplier
    VRMC_spring --> SpringLogic --> SpringNode
    VRMC_vrm --> VRMMeta --> VRMOptions
    VRMC_vrm --> VRMConstants --> VRMExt --> VRMSecondary --> VRMToplevel --> VRMUtils
    VRMC_hdr --> Builder
    Builder --> SceneGraph
    SceneGraph --> Renderer
    Renderer --> Samples
    Samples -->|drags .vrm| FSWatcher
    SceneGraph -->|uses| ShaderMain

    Exporter --> Files
    SceneGraph -->|export| Exporter

    %% Connections to Plugins
    VRMPlugin --> FSWatcher
    MToonPlugin --> SceneGraph

    %% Styles
    classDef core fill:#f2f2f2,stroke:#333,stroke-width:1px
    classDef vrm fill:#cfe2f3,stroke:#333,stroke-width:1px
    classDef mtoon fill:#d9ead3,stroke:#333,stroke-width:1px
    classDef module fill:#fff2cc,stroke:#333,stroke-width:1px
    classDef data fill:#ffe599,stroke:#333,stroke-width:1px
```
