@volter/blender-engine 0.1.147 → 0.1.149
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -0
- package/README.md +4 -11
- package/browser/addons/vrm/LICENSE_(OPTION1)_MIT.txt +22 -0
- package/browser/addons/vrm/LICENSE_(OPTION2)_GPL-3_0.txt +674 -0
- package/browser/addons/vrm/LICENSE_MAIN.txt +1 -0
- package/browser/addons/vrm/README.txt +3 -0
- package/browser/addons/vrm/__init__.py +41 -0
- package/browser/addons/vrm/blender_manifest.toml +16 -0
- package/browser/addons/vrm/common/__init__.py +1 -0
- package/browser/addons/vrm/common/animation.py +58 -0
- package/browser/addons/vrm/common/blender_manifest.py +82 -0
- package/browser/addons/vrm/common/char.py +16 -0
- package/browser/addons/vrm/common/convert.py +287 -0
- package/browser/addons/vrm/common/convert_any.py +48 -0
- package/browser/addons/vrm/common/debug.py +40 -0
- package/browser/addons/vrm/common/deep.py +162 -0
- package/browser/addons/vrm/common/error_dialog.py +274 -0
- package/browser/addons/vrm/common/fs.py +71 -0
- package/browser/addons/vrm/common/gl.py +20 -0
- package/browser/addons/vrm/common/gltf.py +1149 -0
- package/browser/addons/vrm/common/human_bone_mapper/__init__.py +1 -0
- package/browser/addons/vrm/common/human_bone_mapper/biped_mapping.py +84 -0
- package/browser/addons/vrm/common/human_bone_mapper/cats_blender_plugin_fix_model_mapping.py +63 -0
- package/browser/addons/vrm/common/human_bone_mapper/human_bone_mapper.py +203 -0
- package/browser/addons/vrm/common/human_bone_mapper/microsoft_rocketbox_mapping.py +69 -0
- package/browser/addons/vrm/common/human_bone_mapper/mixamo_mapping.py +62 -0
- package/browser/addons/vrm/common/human_bone_mapper/mmd_mapping.py +115 -0
- package/browser/addons/vrm/common/human_bone_mapper/mpfb_mapping.py +120 -0
- package/browser/addons/vrm/common/human_bone_mapper/ready_player_me_mapping.py +65 -0
- package/browser/addons/vrm/common/human_bone_mapper/reallusion_mapping.py +94 -0
- package/browser/addons/vrm/common/human_bone_mapper/rigify_meta_rig_mapping.py +65 -0
- package/browser/addons/vrm/common/human_bone_mapper/structure_based_mapping.py +891 -0
- package/browser/addons/vrm/common/human_bone_mapper/unreal_mapping.py +62 -0
- package/browser/addons/vrm/common/human_bone_mapper/vrm_addon_mapping.py +112 -0
- package/browser/addons/vrm/common/human_bone_mapper/vroid_mapping.py +89 -0
- package/browser/addons/vrm/common/legacy_gltf.py +16 -0
- package/browser/addons/vrm/common/logger.py +84 -0
- package/browser/addons/vrm/common/mtoon0.blend +0 -0
- package/browser/addons/vrm/common/mtoon1.blend +0 -0
- package/browser/addons/vrm/common/mtoon1_outline.blend +0 -0
- package/browser/addons/vrm/common/mtoon_auto_setup.blend +0 -0
- package/browser/addons/vrm/common/mtoon_unversioned.py +62 -0
- package/browser/addons/vrm/common/ops/__init__.py +10 -0
- package/browser/addons/vrm/common/ops/export_scene.py +67 -0
- package/browser/addons/vrm/common/ops/icyp.py +53 -0
- package/browser/addons/vrm/common/ops/import_scene.py +57 -0
- package/browser/addons/vrm/common/ops/vrm.py +2380 -0
- package/browser/addons/vrm/common/ops/wm.py +167 -0
- package/browser/addons/vrm/common/preferences.py +362 -0
- package/browser/addons/vrm/common/progress.py +87 -0
- package/browser/addons/vrm/common/rotation.py +89 -0
- package/browser/addons/vrm/common/safe_removal.py +46 -0
- package/browser/addons/vrm/common/scene_watcher.py +230 -0
- package/browser/addons/vrm/common/shader.py +2243 -0
- package/browser/addons/vrm/common/shape_key_mapper/__init__.py +1 -0
- package/browser/addons/vrm/common/shape_key_mapper/arkit_mapping.py +168 -0
- package/browser/addons/vrm/common/shape_key_mapper/mmd_mapping.py +62 -0
- package/browser/addons/vrm/common/shape_key_mapper/ready_player_me_mapping.py +52 -0
- package/browser/addons/vrm/common/shape_key_mapper/vrchat_mapping.py +17 -0
- package/browser/addons/vrm/common/third_party_user_extension.py +214 -0
- package/browser/addons/vrm/common/transparent_z_write.blend +0 -0
- package/browser/addons/vrm/common/version.py +161 -0
- package/browser/addons/vrm/common/vrm0/__init__.py +1 -0
- package/browser/addons/vrm/common/vrm0/human_bone.py +662 -0
- package/browser/addons/vrm/common/vrm0/material_property.py +346 -0
- package/browser/addons/vrm/common/vrm1/__init__.py +1 -0
- package/browser/addons/vrm/common/vrm1/expression_preset.py +207 -0
- package/browser/addons/vrm/common/vrm1/human_bone.py +822 -0
- package/browser/addons/vrm/common/workspace.py +227 -0
- package/browser/addons/vrm/common/writable_context.py +77 -0
- package/browser/addons/vrm/documentation/en-us/animation/index.md +63 -0
- package/browser/addons/vrm/documentation/en-us/create-humanoid-vrm-from-scratch/index.md +131 -0
- package/browser/addons/vrm/documentation/en-us/create-simple-vrm-from-scratch/index.md +30 -0
- package/browser/addons/vrm/documentation/en-us/development/index.md +136 -0
- package/browser/addons/vrm/documentation/en-us/index.md +41 -0
- package/browser/addons/vrm/documentation/en-us/installation/index.md +152 -0
- package/browser/addons/vrm/documentation/en-us/material-mtoon/index.md +122 -0
- package/browser/addons/vrm/documentation/en-us/material-pbr/index.md +94 -0
- package/browser/addons/vrm/documentation/en-us/scripting-api/index.md +391 -0
- package/browser/addons/vrm/documentation/en-us/ui/export_scene.vrm/index.md +57 -0
- package/browser/addons/vrm/documentation/en-us/ui/export_scene.vrma/index.md +17 -0
- package/browser/addons/vrm/documentation/en-us/ui/import_scene.vrm/index.md +61 -0
- package/browser/addons/vrm/documentation/en-us/ui/import_scene.vrma/index.md +13 -0
- package/browser/addons/vrm/documentation/ja-jp/animation/index.md +57 -0
- package/browser/addons/vrm/documentation/ja-jp/create-humanoid-vrm-from-scratch/index.md +129 -0
- package/browser/addons/vrm/documentation/ja-jp/create-simple-vrm-from-scratch/index.md +29 -0
- package/browser/addons/vrm/documentation/ja-jp/development/index.md +137 -0
- package/browser/addons/vrm/documentation/ja-jp/index.md +37 -0
- package/browser/addons/vrm/documentation/ja-jp/installation/index.md +150 -0
- package/browser/addons/vrm/documentation/ja-jp/material-mtoon/index.md +113 -0
- package/browser/addons/vrm/documentation/ja-jp/material-pbr/index.md +90 -0
- package/browser/addons/vrm/documentation/ja-jp/scripting-api/index.md +389 -0
- package/browser/addons/vrm/documentation/ja-jp/ui/export_scene.vrm/index.md +55 -0
- package/browser/addons/vrm/documentation/ja-jp/ui/export_scene.vrma/index.md +19 -0
- package/browser/addons/vrm/documentation/ja-jp/ui/import_scene.vrm/index.md +56 -0
- package/browser/addons/vrm/documentation/ja-jp/ui/import_scene.vrma/index.md +14 -0
- package/browser/addons/vrm/editor/__init__.py +1 -0
- package/browser/addons/vrm/editor/extension.py +425 -0
- package/browser/addons/vrm/editor/extension_accessor.py +75 -0
- package/browser/addons/vrm/editor/handler.py +84 -0
- package/browser/addons/vrm/editor/khr_character/__init__.py +1 -0
- package/browser/addons/vrm/editor/khr_character/panel.py +69 -0
- package/browser/addons/vrm/editor/khr_character/property_group.py +27 -0
- package/browser/addons/vrm/editor/khr_xmp_json_ld/__init__.py +1 -0
- package/browser/addons/vrm/editor/khr_xmp_json_ld/ops.py +464 -0
- package/browser/addons/vrm/editor/khr_xmp_json_ld/panel.py +136 -0
- package/browser/addons/vrm/editor/khr_xmp_json_ld/property_group.py +83 -0
- package/browser/addons/vrm/editor/khr_xmp_json_ld/ui_list.py +198 -0
- package/browser/addons/vrm/editor/make_armature.py +709 -0
- package/browser/addons/vrm/editor/menu.py +147 -0
- package/browser/addons/vrm/editor/migration.py +297 -0
- package/browser/addons/vrm/editor/mtoon1/__init__.py +1 -0
- package/browser/addons/vrm/editor/mtoon1/handler.py +20 -0
- package/browser/addons/vrm/editor/mtoon1/migration.py +536 -0
- package/browser/addons/vrm/editor/mtoon1/ops.py +304 -0
- package/browser/addons/vrm/editor/mtoon1/panel.py +442 -0
- package/browser/addons/vrm/editor/mtoon1/property_group.py +4977 -0
- package/browser/addons/vrm/editor/mtoon1/scene_watcher.py +381 -0
- package/browser/addons/vrm/editor/node_constraint1/__init__.py +1 -0
- package/browser/addons/vrm/editor/node_constraint1/panel.py +317 -0
- package/browser/addons/vrm/editor/node_constraint1/property_group.py +25 -0
- package/browser/addons/vrm/editor/ops.py +471 -0
- package/browser/addons/vrm/editor/panel.py +315 -0
- package/browser/addons/vrm/editor/property_group.py +888 -0
- package/browser/addons/vrm/editor/search.py +682 -0
- package/browser/addons/vrm/editor/spring_bone1/__init__.py +1 -0
- package/browser/addons/vrm/editor/spring_bone1/handler.py +994 -0
- package/browser/addons/vrm/editor/spring_bone1/menu.py +246 -0
- package/browser/addons/vrm/editor/spring_bone1/migration.py +86 -0
- package/browser/addons/vrm/editor/spring_bone1/ops.py +1679 -0
- package/browser/addons/vrm/editor/spring_bone1/panel.py +605 -0
- package/browser/addons/vrm/editor/spring_bone1/property_group.py +1457 -0
- package/browser/addons/vrm/editor/spring_bone1/ui_list.py +408 -0
- package/browser/addons/vrm/editor/subscription.py +123 -0
- package/browser/addons/vrm/editor/t_pose.py +713 -0
- package/browser/addons/vrm/editor/validation.py +1271 -0
- package/browser/addons/vrm/editor/vrm0/__init__.py +1 -0
- package/browser/addons/vrm/editor/vrm0/gizmo_group.py +63 -0
- package/browser/addons/vrm/editor/vrm0/handler.py +23 -0
- package/browser/addons/vrm/editor/vrm0/menu.py +145 -0
- package/browser/addons/vrm/editor/vrm0/migration.py +761 -0
- package/browser/addons/vrm/editor/vrm0/ops.py +2145 -0
- package/browser/addons/vrm/editor/vrm0/panel.py +1333 -0
- package/browser/addons/vrm/editor/vrm0/property_group.py +1818 -0
- package/browser/addons/vrm/editor/vrm0/ui_list.py +688 -0
- package/browser/addons/vrm/editor/vrm1/__init__.py +1 -0
- package/browser/addons/vrm/editor/vrm1/handler.py +28 -0
- package/browser/addons/vrm/editor/vrm1/menu.py +76 -0
- package/browser/addons/vrm/editor/vrm1/migration.py +321 -0
- package/browser/addons/vrm/editor/vrm1/ops.py +2679 -0
- package/browser/addons/vrm/editor/vrm1/panel.py +1243 -0
- package/browser/addons/vrm/editor/vrm1/property_group.py +2087 -0
- package/browser/addons/vrm/editor/vrm1/scene_watcher.py +90 -0
- package/browser/addons/vrm/editor/vrm1/ui_list.py +533 -0
- package/browser/addons/vrm/exporter/__init__.py +1 -0
- package/browser/addons/vrm/exporter/abstract_base_vrm_exporter.py +628 -0
- package/browser/addons/vrm/exporter/export_scene.py +930 -0
- package/browser/addons/vrm/exporter/gltf2_export_user_extension.py +45 -0
- package/browser/addons/vrm/exporter/khr_character_exporter.py +34 -0
- package/browser/addons/vrm/exporter/vrm0_exporter.py +4020 -0
- package/browser/addons/vrm/exporter/vrm1_exporter.py +3682 -0
- package/browser/addons/vrm/exporter/vrm_animation_exporter.py +1035 -0
- package/browser/addons/vrm/external/__init__.py +1 -0
- package/browser/addons/vrm/external/auto_rig_pro_support.py +3 -0
- package/browser/addons/vrm/external/io_scene_gltf2_support.py +418 -0
- package/browser/addons/vrm/external/rigify_support.py +1 -0
- package/browser/addons/vrm/importer/__init__.py +1 -0
- package/browser/addons/vrm/importer/abstract_base_vrm_importer.py +1548 -0
- package/browser/addons/vrm/importer/file_handler.py +34 -0
- package/browser/addons/vrm/importer/gltf2_import_user_extension.py +268 -0
- package/browser/addons/vrm/importer/import_scene.py +646 -0
- package/browser/addons/vrm/importer/license_validation.py +198 -0
- package/browser/addons/vrm/importer/vrm0_importer.py +1723 -0
- package/browser/addons/vrm/importer/vrm1_importer.py +2014 -0
- package/browser/addons/vrm/importer/vrm_animation_importer.py +763 -0
- package/browser/addons/vrm/importer/vrm_diff.py +316 -0
- package/browser/addons/vrm/locale/__init__.py +1 -0
- package/browser/addons/vrm/locale/ja_jp.py +826 -0
- package/browser/addons/vrm/locale/ruff.toml +8 -0
- package/browser/addons/vrm/locale/translation_dictionary.py +10 -0
- package/browser/addons/vrm/locale/zh_hans.py +928 -0
- package/browser/addons/vrm/registration.py +670 -0
- package/browser/addons/vrm.json +18 -0
- package/browser/blender-emscripten-engine.mts +60 -128
- package/browser/blender-engine.mts +20 -186
- package/browser/blender-wali-engine.mts +35 -81
- package/browser/describe-thrown.mts +3 -6
- package/browser/document-chunks.mts +4 -16
- package/browser/gltf_export.py +3161 -0
- package/browser/heap-growth.mts +23 -0
- package/browser/index.ts +2 -0
- package/browser/protocol.ts +119 -35
- package/browser/pull-job.mts +2 -10
- package/browser/rna.ts +190 -73
- package/browser/runtime.ts +197 -82
- package/browser/session-addons.mts +33 -0
- package/browser/session-frame.mts +5 -24
- package/browser/session.py +1338 -1427
- package/browser/three/attach-presenter.ts +11 -39
- package/browser/three/blender-base64.ts +1 -36
- package/browser/three/blender-corner-normals.ts +1 -23
- package/browser/three/blender-display-shaders.json +1 -1
- package/browser/three/blender-display-shaders.lut +0 -0
- package/browser/three/blender-display-transform.ts +2 -1
- package/browser/three/blender-frame-columns.ts +5 -13
- package/browser/three/blender-graph-material.ts +18 -3
- package/browser/three/blender-node-graph.ts +10 -34
- package/browser/three/blender-physical-material.ts +2 -31
- package/browser/three/blender-runtime-armature.ts +7 -60
- package/browser/three/blender-runtime-frame.ts +9 -23
- package/browser/three/blender-runtime-geometry.ts +22 -26
- package/browser/three/blender-runtime-lighting.ts +48 -178
- package/browser/three/blender-runtime-shadows.ts +187 -1
- package/browser/three/blender-runtime-skeleton.ts +53 -1
- package/browser/three/blender-runtime-view.ts +505 -283
- package/browser/three/blender-runtime-weights.ts +9 -72
- package/browser/three/blender-sky.ts +13 -33
- package/browser/three/blender-triangulate.ts +7 -35
- package/browser/three/blender-viewport-sampling.ts +235 -0
- package/browser/three/blender-workbench-material.ts +25 -29
- package/browser/three/blender-workbench-outline.ts +199 -0
- package/browser/three/blender-world-volume.ts +62 -10
- package/browser/three/presenter.ts +10 -26
- package/browser/three/release.ts +5 -21
- package/browser/three/sky-precompute-worker.ts +1 -18
- package/browser/three/sky-worker.ts +5 -23
- package/browser/three/world-field-sampler.ts +12 -26
- package/browser/volter_three.py +9 -105
- package/browser/worker.ts +156 -151
- package/package.json +5 -2
- package/wasm/BUNDLE.json +17 -17
- package/wasm/DEPENDENCY-LICENSES.txt +14 -0
- package/wasm/blender_browser.data.br +0 -0
- package/wasm/blender_browser.js +1 -1
- package/wasm/blender_browser.wasm.br +0 -0
- package/browser/frame-transfer.mts +0 -19
- package/browser/three/agx-base-srgb.lut +0 -0
- package/browser/three/agx-look-medium-high-contrast.lut +0 -0
- package/browser/three/agx-look-punchy.lut +0 -0
- package/browser/three/blender-agx.ts +0 -235
- package/browser/three/blender-display-lut.ts +0 -145
- package/browser/three/blender-filmic.ts +0 -49
- package/browser/three/blender-standard.ts +0 -68
- package/browser/three/blender-world-visibility.ts +0 -278
- package/browser/three/filmic-srgb.lut +0 -0
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT OR GPL-3.0-or-later
|
|
2
|
+
from typing import Optional
|
|
3
|
+
|
|
4
|
+
import bpy
|
|
5
|
+
from bpy.app.translations import pgettext
|
|
6
|
+
from bpy.types import Context, Panel, PropertyGroup, UILayout
|
|
7
|
+
|
|
8
|
+
from ...common.logger import get_logger
|
|
9
|
+
from ...common.shader import LegacyAddonMaterial, MmdMaterial
|
|
10
|
+
from ..extension_accessor import get_material_extension
|
|
11
|
+
from ..ops import VRM_OT_open_url_in_web_browser, layout_operator
|
|
12
|
+
from .ops import (
|
|
13
|
+
VRM_OT_import_mtoon1_texture_image_file,
|
|
14
|
+
VRM_OT_reset_mtoon1_material_shader_node_tree,
|
|
15
|
+
)
|
|
16
|
+
from .property_group import (
|
|
17
|
+
Mtoon0TexturePropertyGroup,
|
|
18
|
+
Mtoon1MaterialPropertyGroup,
|
|
19
|
+
Mtoon1TextureInfoPropertyGroup,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
_logger = get_logger(__name__)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _draw_texture_info(
|
|
26
|
+
material_name: str,
|
|
27
|
+
ext: Mtoon1MaterialPropertyGroup,
|
|
28
|
+
parent_layout: UILayout,
|
|
29
|
+
base_property_group: PropertyGroup,
|
|
30
|
+
texture_info_attr_name: str,
|
|
31
|
+
color_factor_attr_name: Optional[str] = None,
|
|
32
|
+
) -> UILayout:
|
|
33
|
+
texture_info = getattr(base_property_group, texture_info_attr_name, None)
|
|
34
|
+
if not isinstance(texture_info, Mtoon1TextureInfoPropertyGroup):
|
|
35
|
+
raise TypeError
|
|
36
|
+
layout = parent_layout.split(factor=0.3)
|
|
37
|
+
toggle_layout = layout.row()
|
|
38
|
+
toggle_layout.alignment = "LEFT"
|
|
39
|
+
toggle_layout.prop(
|
|
40
|
+
texture_info,
|
|
41
|
+
"show_expanded",
|
|
42
|
+
emboss=False,
|
|
43
|
+
text=texture_info.index.panel_label,
|
|
44
|
+
translate=False,
|
|
45
|
+
icon="TRIA_DOWN" if texture_info.show_expanded else "TRIA_RIGHT",
|
|
46
|
+
)
|
|
47
|
+
input_layout = layout.row(align=True)
|
|
48
|
+
|
|
49
|
+
node_image = texture_info.index.get_connected_node_image()
|
|
50
|
+
if node_image == texture_info.index.source:
|
|
51
|
+
source_prop_name = "source"
|
|
52
|
+
placeholder = ""
|
|
53
|
+
else:
|
|
54
|
+
source_prop_name = "source_for_desynced_node_tree"
|
|
55
|
+
placeholder = node_image.name if node_image else ""
|
|
56
|
+
|
|
57
|
+
if bpy.app.version >= (4, 1):
|
|
58
|
+
input_layout.prop(
|
|
59
|
+
texture_info.index,
|
|
60
|
+
source_prop_name,
|
|
61
|
+
text="",
|
|
62
|
+
translate=False,
|
|
63
|
+
placeholder=placeholder,
|
|
64
|
+
)
|
|
65
|
+
else:
|
|
66
|
+
input_layout.prop(
|
|
67
|
+
texture_info.index,
|
|
68
|
+
source_prop_name,
|
|
69
|
+
text="",
|
|
70
|
+
translate=False,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
import_image_file_op = layout_operator(
|
|
74
|
+
input_layout,
|
|
75
|
+
VRM_OT_import_mtoon1_texture_image_file,
|
|
76
|
+
text="",
|
|
77
|
+
translate=False,
|
|
78
|
+
icon="FILEBROWSER",
|
|
79
|
+
)
|
|
80
|
+
import_image_file_op.material_name = material_name
|
|
81
|
+
import_image_file_op.target_texture = type(texture_info.index).__name__
|
|
82
|
+
if color_factor_attr_name:
|
|
83
|
+
input_layout.separator(factor=0.5)
|
|
84
|
+
input_layout.prop(base_property_group, color_factor_attr_name, text="")
|
|
85
|
+
|
|
86
|
+
if not texture_info.show_expanded:
|
|
87
|
+
return input_layout
|
|
88
|
+
|
|
89
|
+
box = parent_layout.box().column()
|
|
90
|
+
if texture_info.index.source:
|
|
91
|
+
box.prop(texture_info.index.source.colorspace_settings, "name")
|
|
92
|
+
if (
|
|
93
|
+
texture_info.index.source.colorspace_settings.name
|
|
94
|
+
!= texture_info.index.colorspace
|
|
95
|
+
):
|
|
96
|
+
box.box().label(
|
|
97
|
+
text=pgettext(
|
|
98
|
+
'It is recommended to set "{colorspace}"'
|
|
99
|
+
+ ' to "{input_colorspace}" for "{texture_label}"'
|
|
100
|
+
).format(
|
|
101
|
+
texture_label=texture_info.index.label,
|
|
102
|
+
colorspace=pgettext(texture_info.index.colorspace),
|
|
103
|
+
input_colorspace=pgettext("Input Color Space"),
|
|
104
|
+
),
|
|
105
|
+
icon="ERROR",
|
|
106
|
+
)
|
|
107
|
+
box.prop(texture_info.index.sampler, "mag_filter")
|
|
108
|
+
box.prop(texture_info.index.sampler, "min_filter")
|
|
109
|
+
box.prop(texture_info.index.sampler, "wrap_s")
|
|
110
|
+
box.prop(texture_info.index.sampler, "wrap_t")
|
|
111
|
+
|
|
112
|
+
if ext.pbr_metallic_roughness.base_color_texture == texture_info:
|
|
113
|
+
box.prop(texture_info.extensions.khr_texture_transform, "offset")
|
|
114
|
+
box.prop(texture_info.extensions.khr_texture_transform, "scale")
|
|
115
|
+
elif texture_info in {
|
|
116
|
+
ext.extensions.vrmc_materials_mtoon.matcap_texture,
|
|
117
|
+
ext.extensions.vrmc_materials_mtoon.outline_width_multiply_texture,
|
|
118
|
+
}:
|
|
119
|
+
pass
|
|
120
|
+
else:
|
|
121
|
+
box.box().label(
|
|
122
|
+
text="Offset and Scale are the values of the Lit Color Texture.",
|
|
123
|
+
icon="INFO",
|
|
124
|
+
)
|
|
125
|
+
return input_layout
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _draw_mtoon0_texture(
|
|
129
|
+
material_name: str,
|
|
130
|
+
parent_layout: UILayout,
|
|
131
|
+
base_property_group: PropertyGroup,
|
|
132
|
+
texture_attr_name: str,
|
|
133
|
+
scalar_factor_attr_name: str,
|
|
134
|
+
) -> UILayout:
|
|
135
|
+
texture = getattr(base_property_group, texture_attr_name, None)
|
|
136
|
+
if not isinstance(texture, Mtoon0TexturePropertyGroup):
|
|
137
|
+
raise TypeError
|
|
138
|
+
layout = parent_layout.split(factor=0.3)
|
|
139
|
+
toggle_layout = layout.row()
|
|
140
|
+
toggle_layout.alignment = "LEFT"
|
|
141
|
+
toggle_layout.prop(
|
|
142
|
+
texture,
|
|
143
|
+
"show_expanded",
|
|
144
|
+
emboss=False,
|
|
145
|
+
text=texture.panel_label,
|
|
146
|
+
translate=False,
|
|
147
|
+
icon="TRIA_DOWN" if texture.show_expanded else "TRIA_RIGHT",
|
|
148
|
+
)
|
|
149
|
+
input_layout = layout.row(align=True)
|
|
150
|
+
input_layout.prop(texture, "source", text="")
|
|
151
|
+
import_image_file_op = layout_operator(
|
|
152
|
+
input_layout,
|
|
153
|
+
VRM_OT_import_mtoon1_texture_image_file,
|
|
154
|
+
text="",
|
|
155
|
+
translate=False,
|
|
156
|
+
icon="FILEBROWSER",
|
|
157
|
+
)
|
|
158
|
+
import_image_file_op.material_name = material_name
|
|
159
|
+
import_image_file_op.target_texture = type(texture).__name__
|
|
160
|
+
|
|
161
|
+
input_layout.separator(factor=0.5)
|
|
162
|
+
input_layout.prop(base_property_group, scalar_factor_attr_name, text="")
|
|
163
|
+
|
|
164
|
+
if not texture.show_expanded:
|
|
165
|
+
return input_layout
|
|
166
|
+
|
|
167
|
+
box = parent_layout.box().column()
|
|
168
|
+
if texture.source:
|
|
169
|
+
box.prop(texture.source.colorspace_settings, "name")
|
|
170
|
+
if texture.source.colorspace_settings.name != texture.colorspace:
|
|
171
|
+
box.box().label(
|
|
172
|
+
text=pgettext(
|
|
173
|
+
'It is recommended to set "{colorspace}"'
|
|
174
|
+
+ ' to "{input_colorspace}" for "{texture_label}"'
|
|
175
|
+
).format(
|
|
176
|
+
texture_label=texture.label,
|
|
177
|
+
colorspace=pgettext(texture.colorspace),
|
|
178
|
+
input_colorspace=pgettext("Input Color Space"),
|
|
179
|
+
),
|
|
180
|
+
icon="ERROR",
|
|
181
|
+
)
|
|
182
|
+
box.prop(texture.sampler, "mag_filter")
|
|
183
|
+
box.prop(texture.sampler, "min_filter")
|
|
184
|
+
box.prop(texture.sampler, "wrap_s")
|
|
185
|
+
box.prop(texture.sampler, "wrap_t")
|
|
186
|
+
return input_layout
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
def _draw_mtoon1_material(context: Context, layout: UILayout) -> None:
|
|
190
|
+
material = context.material
|
|
191
|
+
if not material:
|
|
192
|
+
return
|
|
193
|
+
ext = get_material_extension(material)
|
|
194
|
+
layout = layout.column()
|
|
195
|
+
|
|
196
|
+
layout.prop(ext.mtoon1, "enabled")
|
|
197
|
+
if not ext.mtoon1.enabled:
|
|
198
|
+
return
|
|
199
|
+
|
|
200
|
+
gltf = ext.mtoon1
|
|
201
|
+
mtoon = gltf.extensions.vrmc_materials_mtoon
|
|
202
|
+
|
|
203
|
+
# https://github.com/vrm-c/UniVRM/blob/v0.102.0/Assets/VRMShaders/VRM10/MToon10/Editor/MToonInspector.cs#L14
|
|
204
|
+
layout.label(text="Rendering", translate=False)
|
|
205
|
+
rendering_box = layout.box().column()
|
|
206
|
+
rendering_box.prop(gltf, "alpha_mode")
|
|
207
|
+
if gltf.alpha_mode == gltf.ALPHA_MODE_MASK.identifier:
|
|
208
|
+
rendering_box.prop(gltf, "alpha_cutoff", slider=True)
|
|
209
|
+
if gltf.alpha_mode == gltf.ALPHA_MODE_BLEND.identifier:
|
|
210
|
+
rendering_box.prop(mtoon, "transparent_with_z_write")
|
|
211
|
+
rendering_box.prop(gltf, "double_sided")
|
|
212
|
+
rendering_box.prop(mtoon, "render_queue_offset_number", slider=True)
|
|
213
|
+
|
|
214
|
+
layout.label(text="Lighting", translate=False)
|
|
215
|
+
lighting_box = layout.box().column()
|
|
216
|
+
_draw_texture_info(
|
|
217
|
+
material.name,
|
|
218
|
+
ext.mtoon1,
|
|
219
|
+
lighting_box,
|
|
220
|
+
gltf.pbr_metallic_roughness,
|
|
221
|
+
"base_color_texture",
|
|
222
|
+
"base_color_factor",
|
|
223
|
+
)
|
|
224
|
+
_draw_texture_info(
|
|
225
|
+
material.name,
|
|
226
|
+
ext.mtoon1,
|
|
227
|
+
lighting_box,
|
|
228
|
+
mtoon,
|
|
229
|
+
"shade_multiply_texture",
|
|
230
|
+
"shade_color_factor",
|
|
231
|
+
)
|
|
232
|
+
normal_texture_layout = _draw_texture_info(
|
|
233
|
+
material.name,
|
|
234
|
+
ext.mtoon1,
|
|
235
|
+
lighting_box,
|
|
236
|
+
gltf,
|
|
237
|
+
"normal_texture",
|
|
238
|
+
)
|
|
239
|
+
normal_texture_layout.separator(factor=0.5)
|
|
240
|
+
normal_texture_layout.prop(gltf.normal_texture, "scale")
|
|
241
|
+
|
|
242
|
+
lighting_box.prop(mtoon, "shading_toony_factor", slider=True)
|
|
243
|
+
lighting_box.prop(mtoon, "shading_shift_factor", slider=True)
|
|
244
|
+
shading_shift_texture_layout = _draw_texture_info(
|
|
245
|
+
material.name,
|
|
246
|
+
ext.mtoon1,
|
|
247
|
+
lighting_box,
|
|
248
|
+
mtoon,
|
|
249
|
+
"shading_shift_texture",
|
|
250
|
+
)
|
|
251
|
+
shading_shift_texture_layout.separator(factor=0.5)
|
|
252
|
+
shading_shift_texture_layout.prop(mtoon.shading_shift_texture, "scale")
|
|
253
|
+
|
|
254
|
+
# UniVRM (MIT License)
|
|
255
|
+
# https://github.com/vrm-c/UniVRM/blob/d2b4ad1964b754341873f2a1b093d58e1df1713f/Assets/VRMShaders/VRM10/MToon10/Editor/MToonInspector.cs#L120-L128
|
|
256
|
+
if (
|
|
257
|
+
not mtoon.shading_shift_texture.index.source
|
|
258
|
+
and mtoon.shading_toony_factor - mtoon.shading_shift_factor < 1.0 - 0.001
|
|
259
|
+
):
|
|
260
|
+
lighting_box.box().label(
|
|
261
|
+
text="The lit area includes non-lit area.", icon="ERROR"
|
|
262
|
+
)
|
|
263
|
+
|
|
264
|
+
layout.label(text="Global Illumination", translate=False)
|
|
265
|
+
gi_box = layout.box()
|
|
266
|
+
gi_box.prop(mtoon, "gi_equalization_factor", slider=True)
|
|
267
|
+
|
|
268
|
+
layout.label(text="Emission", translate=False)
|
|
269
|
+
emission_box = layout.box().column()
|
|
270
|
+
emissive_texture_layout = _draw_texture_info(
|
|
271
|
+
material.name,
|
|
272
|
+
ext.mtoon1,
|
|
273
|
+
emission_box,
|
|
274
|
+
gltf,
|
|
275
|
+
"emissive_texture",
|
|
276
|
+
).row(align=True)
|
|
277
|
+
emissive_texture_layout.scale_x = 0.71
|
|
278
|
+
emissive_texture_layout.separator(factor=0.5 / 0.71)
|
|
279
|
+
emissive_texture_layout.prop(gltf, "emissive_factor", text="")
|
|
280
|
+
emissive_texture_layout.prop(
|
|
281
|
+
gltf.extensions.khr_materials_emissive_strength, "emissive_strength"
|
|
282
|
+
)
|
|
283
|
+
|
|
284
|
+
layout.label(text="Rim Lighting", translate=False)
|
|
285
|
+
rim_lighting_box = layout.box().column()
|
|
286
|
+
_draw_texture_info(
|
|
287
|
+
material.name,
|
|
288
|
+
ext.mtoon1,
|
|
289
|
+
rim_lighting_box,
|
|
290
|
+
mtoon,
|
|
291
|
+
"rim_multiply_texture",
|
|
292
|
+
)
|
|
293
|
+
rim_lighting_box.prop(mtoon, "rim_lighting_mix_factor", slider=True)
|
|
294
|
+
_draw_texture_info(
|
|
295
|
+
material.name,
|
|
296
|
+
ext.mtoon1,
|
|
297
|
+
rim_lighting_box,
|
|
298
|
+
mtoon,
|
|
299
|
+
"matcap_texture",
|
|
300
|
+
"matcap_factor",
|
|
301
|
+
)
|
|
302
|
+
rim_lighting_box.row().prop(mtoon, "parametric_rim_color_factor")
|
|
303
|
+
rim_lighting_box.prop(mtoon, "parametric_rim_fresnel_power_factor", slider=True)
|
|
304
|
+
rim_lighting_box.prop(mtoon, "parametric_rim_lift_factor", slider=True)
|
|
305
|
+
|
|
306
|
+
layout.label(text="Outline", translate=False)
|
|
307
|
+
outline_box = layout.box().column()
|
|
308
|
+
outline_box.prop(mtoon, "outline_width_mode")
|
|
309
|
+
if (
|
|
310
|
+
bpy.app.version >= (3, 3)
|
|
311
|
+
and mtoon.outline_width_mode
|
|
312
|
+
== mtoon.OUTLINE_WIDTH_MODE_SCREEN_COORDINATES.identifier
|
|
313
|
+
):
|
|
314
|
+
outline_warning_message = pgettext(
|
|
315
|
+
'The "Screen Coordinates" display is not yet implemented.\n'
|
|
316
|
+
+ 'It is displayed in the same way as "World Coordinates".'
|
|
317
|
+
)
|
|
318
|
+
outline_warning_column = outline_box.box().column(align=True)
|
|
319
|
+
for index, outline_warning_line in enumerate(
|
|
320
|
+
outline_warning_message.splitlines()
|
|
321
|
+
):
|
|
322
|
+
outline_warning_column.label(
|
|
323
|
+
text=outline_warning_line,
|
|
324
|
+
translate=False,
|
|
325
|
+
icon="BLANK1" if index else "INFO",
|
|
326
|
+
)
|
|
327
|
+
if mtoon.outline_width_mode != mtoon.OUTLINE_WIDTH_MODE_NONE.identifier:
|
|
328
|
+
outline_width_multiply_texture_layout = _draw_texture_info(
|
|
329
|
+
material.name,
|
|
330
|
+
ext.mtoon1,
|
|
331
|
+
outline_box,
|
|
332
|
+
mtoon,
|
|
333
|
+
"outline_width_multiply_texture",
|
|
334
|
+
)
|
|
335
|
+
outline_width_multiply_texture_layout.separator(factor=0.5)
|
|
336
|
+
outline_width_multiply_texture_layout.prop(
|
|
337
|
+
mtoon, "outline_width_factor", slider=True, text=""
|
|
338
|
+
)
|
|
339
|
+
outline_box.row().prop(mtoon, "outline_color_factor")
|
|
340
|
+
outline_box.prop(mtoon, "outline_lighting_mix_factor", slider=True)
|
|
341
|
+
outline_box.prop(mtoon, "enable_outline_preview", text="Enable Preview")
|
|
342
|
+
|
|
343
|
+
layout.label(text="UV Animation", translate=False)
|
|
344
|
+
uv_animation_box = layout.box().column()
|
|
345
|
+
_draw_texture_info(
|
|
346
|
+
material.name,
|
|
347
|
+
ext.mtoon1,
|
|
348
|
+
uv_animation_box,
|
|
349
|
+
mtoon,
|
|
350
|
+
"uv_animation_mask_texture",
|
|
351
|
+
)
|
|
352
|
+
uv_animation_box.prop(mtoon, "uv_animation_scroll_x_speed_factor")
|
|
353
|
+
uv_animation_box.prop(mtoon, "uv_animation_scroll_y_speed_factor")
|
|
354
|
+
uv_animation_box.prop(mtoon, "uv_animation_rotation_speed_factor")
|
|
355
|
+
|
|
356
|
+
layout.prop(gltf, "show_expanded_mtoon0")
|
|
357
|
+
if gltf.show_expanded_mtoon0:
|
|
358
|
+
mtoon0_box = layout.box().column()
|
|
359
|
+
mtoon0_box.prop(gltf, "mtoon0_front_cull_mode")
|
|
360
|
+
_draw_mtoon0_texture(
|
|
361
|
+
material.name,
|
|
362
|
+
mtoon0_box,
|
|
363
|
+
ext.mtoon1,
|
|
364
|
+
"mtoon0_receive_shadow_texture",
|
|
365
|
+
"mtoon0_receive_shadow_rate",
|
|
366
|
+
)
|
|
367
|
+
_draw_mtoon0_texture(
|
|
368
|
+
material.name,
|
|
369
|
+
mtoon0_box,
|
|
370
|
+
ext.mtoon1,
|
|
371
|
+
"mtoon0_shading_grade_texture",
|
|
372
|
+
"mtoon0_shading_grade_rate",
|
|
373
|
+
)
|
|
374
|
+
mtoon0_box.prop(gltf, "mtoon0_light_color_attenuation", slider=True)
|
|
375
|
+
mtoon0_box.prop(gltf, "mtoon0_rim_lighting_mix", slider=True)
|
|
376
|
+
mtoon0_box.prop(gltf, "mtoon0_outline_scaled_max_distance", slider=True)
|
|
377
|
+
mtoon0_box.prop(gltf, "mtoon0_render_queue_and_clamp", slider=True)
|
|
378
|
+
|
|
379
|
+
reset_op = layout_operator(layout, VRM_OT_reset_mtoon1_material_shader_node_tree)
|
|
380
|
+
reset_op.material_name = material.name
|
|
381
|
+
|
|
382
|
+
|
|
383
|
+
def _draw_material(context: Context, layout: UILayout) -> None:
|
|
384
|
+
material = context.material
|
|
385
|
+
if not material:
|
|
386
|
+
return
|
|
387
|
+
ext = get_material_extension(material)
|
|
388
|
+
if ext.mtoon1.is_outline_material:
|
|
389
|
+
layout.box().label(icon="INFO", text="This is an MToon Outline material")
|
|
390
|
+
return
|
|
391
|
+
|
|
392
|
+
_draw_mtoon1_material(context, layout)
|
|
393
|
+
|
|
394
|
+
legacy_addon_material = LegacyAddonMaterial.try_parse(material)
|
|
395
|
+
if ext.mtoon1.enabled or (
|
|
396
|
+
legacy_addon_material
|
|
397
|
+
and legacy_addon_material.shader_name == "MToon_unversioned"
|
|
398
|
+
):
|
|
399
|
+
layout.prop(ext.mtoon1, "export_shape_key_normals")
|
|
400
|
+
return
|
|
401
|
+
if legacy_addon_material and legacy_addon_material.shader_name in (
|
|
402
|
+
"TRANSPARENT_ZWRITE",
|
|
403
|
+
"GLTF",
|
|
404
|
+
):
|
|
405
|
+
return
|
|
406
|
+
if MmdMaterial.try_parse(material):
|
|
407
|
+
return
|
|
408
|
+
|
|
409
|
+
help_column = layout.box().column(align=True)
|
|
410
|
+
help_message = pgettext(
|
|
411
|
+
"How to export this material to VRM.\n"
|
|
412
|
+
+ "Meet one of the following conditions.\n"
|
|
413
|
+
+ " - VRM MToon Material is enabled\n"
|
|
414
|
+
+ ' - Connect the "Surface" to a "Principled BSDF"\n'
|
|
415
|
+
+ ' - Connect the "Surface" to a "MToon_unversioned"\n'
|
|
416
|
+
+ ' - Connect the "Surface" to a "TRANSPARENT_ZWRITE"\n'
|
|
417
|
+
+ " - Others that are compatible with the glTF 2.0 add-on export\n"
|
|
418
|
+
)
|
|
419
|
+
for index, help_line in enumerate(help_message.splitlines()):
|
|
420
|
+
help_column.label(
|
|
421
|
+
text=help_line, translate=False, icon="HELP" if index == 0 else "NONE"
|
|
422
|
+
)
|
|
423
|
+
url = "https://docs.blender.org/manual/en/2.93/addons/import_export/scene_gltf2.html#exported-materials"
|
|
424
|
+
link_row = help_column.split(factor=0.8)
|
|
425
|
+
link_row.label(text=" " + url, translate=False)
|
|
426
|
+
web_op = layout_operator(link_row, VRM_OT_open_url_in_web_browser, icon="URL")
|
|
427
|
+
web_op.url = url
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
class VRM_PT_vrm_material_property(Panel):
|
|
431
|
+
bl_idname = "VRM_PT_vrm_material_property"
|
|
432
|
+
bl_label = "VRM Material"
|
|
433
|
+
bl_space_type = "PROPERTIES"
|
|
434
|
+
bl_region_type = "WINDOW"
|
|
435
|
+
bl_context = "material"
|
|
436
|
+
|
|
437
|
+
@classmethod
|
|
438
|
+
def poll(cls, context: Context) -> bool:
|
|
439
|
+
return bool(context.material)
|
|
440
|
+
|
|
441
|
+
def draw(self, context: Context) -> None:
|
|
442
|
+
_draw_material(context, self.layout)
|