Skip to content

Commit

Permalink
feat: Blender 4.2 + legacy shader node group warning
Browse files Browse the repository at this point in the history
  • Loading branch information
saturday06 committed Sep 7, 2024
1 parent 2b2fe5e commit ff45476
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 31 deletions.
8 changes: 8 additions & 0 deletions src/io_scene_vrm/editor/mtoon1/migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ...common.gl import GL_LINEAR, GL_NEAREST
from ...common.logging import get_logger
from ...common.progress import create_progress
from .. import search
from ..extension import get_material_extension
from .property_group import (
GL_LINEAR_IMAGE_INTERPOLATIONS,
Expand Down Expand Up @@ -88,6 +89,13 @@ def migrate_material(
material: Material,
blender_4_2_migrated_material_names: list[str],
) -> None:
_, legacy_vrm_shader_name = search.vrm_shader_node(material)
if legacy_vrm_shader_name in search.LEGACY_VRM_SHADER_NAMES:
# 古いシェーダーノードグループはそのままではBlender 4.2に未対応なので、
# Blender 4.2以降へのバージョンアップ時は必ず警告する
blender_4_2_migrated_material_names.append(material.name)
return

if not material.use_nodes:
return
node_tree = material.node_tree
Expand Down
6 changes: 1 addition & 5 deletions src/io_scene_vrm/editor/mtoon1/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,11 +1099,7 @@ def draw(self, _context: Context) -> None:
+ " to implement automatic migration of old settings values because those"
+ " values could no longer be read.\n"
+ 'Please check the "{alpha_mode}" settings for materials that have'
+ " MToon enabled. "
+ "Alternatively, if you open and save the \ncurrent file using the latest"
+ " version of Blender 3.6 and the VRM add-on, the data for automatic"
+ " migration will be created \ninternally, so that file can be opened in"
+ " Blender 4.2 or later without losing the material settings.\n"
+ " MToon enabled.\n"
+ "Materials that may be affected are as follows:"
).format(
blend_mode=pgettext("Blend Mode"),
Expand Down
9 changes: 8 additions & 1 deletion src/io_scene_vrm/editor/search.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Optional, Union
from typing import Final, Optional, Union

from bpy.app.translations import pgettext
from bpy.types import (
Expand Down Expand Up @@ -70,6 +70,13 @@ def export_materials(context: Context, objects: list[Object]) -> list[Material]:
return result


LEGACY_VRM_SHADER_NAMES: Final = (
"MToon_unversioned",
"GLTF",
"TRANSPARENT_ZWRITE",
)


def vrm_shader_node(
material: Material,
) -> tuple[Optional[ShaderNodeGroup], Optional[str]]:
Expand Down
12 changes: 5 additions & 7 deletions src/io_scene_vrm/editor/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,6 @@ def detect_errors(
continue

links = node.inputs["Surface"].links
groups = [
"MToon_unversioned",
"GLTF",
"TRANSPARENT_ZWRITE",
]

if links and links[0].from_node.type == "BSDF_PRINCIPLED":
continue

Expand All @@ -619,7 +613,11 @@ def detect_errors(
from_node, ShaderNodeGroup
):
node_tree = from_node.node_tree
if node_tree and node_tree.get("SHADER") in groups:
if (
node_tree
and node_tree.get("SHADER")
in search.LEGACY_VRM_SHADER_NAMES
):
continue

skippable_warning_messages.append(
Expand Down
10 changes: 1 addition & 9 deletions src/io_scene_vrm/locale/ja_jp.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,11 +570,7 @@
+ " to implement automatic migration of old settings values because those"
+ " values could no longer be read.\n"
+ 'Please check the "{alpha_mode}" settings for materials that have'
+ " MToon enabled. "
+ "Alternatively, if you open and save the \ncurrent file using the latest"
+ " version of Blender 3.6 and the VRM add-on, the data for automatic"
+ " migration will be created \ninternally, so that file can be opened in"
+ " Blender 4.2 or later without losing the material settings.\n"
+ " MToon enabled.\n"
+ "Materials that may be affected are as follows:",
): "Blender 4.2へのアップデートに伴い、一部のMToonマテリアルの"
+ "「{alpha_mode}」設定が意図せず「{transparent}」に変化している\n"
Expand All @@ -585,10 +581,6 @@
+ "されましたが、古い設定値の自動移行は、\n"
+ "古い設定値自体がもう読めないため実装が不可能でした。"
+ "MToonが有効なマテリアルの「{alpha_mode}」設定の確認をお願いします。\n"
+ "あるいは、Blender 3.6とVRMアドオンの最新版で現在のファイルを"
+ "一度開いて保存すると、内部的に自動移行用のデータが作成\n"
+ "されるため、そのファイルはマテリアルの設定を失わずに"
+ "Blender 4.2以降でも開けるようになります。\n"
+ "影響のある可能性のあるマテリアルは次の通りです。",
(
"Operator",
Expand Down
10 changes: 1 addition & 9 deletions src/io_scene_vrm/locale/zh_hans.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,11 +550,7 @@
+ " to implement automatic migration of old settings values because those"
+ " values could no longer be read.\n"
+ 'Please check the "{alpha_mode}" settings for materials that have'
+ " MToon enabled. "
+ "Alternatively, if you open and save the \ncurrent file using the latest"
+ " version of Blender 3.6 and the VRM add-on, the data for automatic"
+ " migration will be created \ninternally, so that file can be opened in"
+ " Blender 4.2 or later without losing the material settings.\n"
+ " MToon enabled.\n"
+ "Materials that may be affected are as follows:",
): "升级到 Blender 4.2可能会无意间改变一些MOOT材质的"
+ "「{alpha_mode}」为「{transparent}」\n"
Expand All @@ -564,9 +560,5 @@
+ "但是无法自动迁移旧的配置 因为这些参数无法读取了\n"
+ "请检查材质「{alpha_mode}」设置中。"
+ "具有MToon启动\n"
+ "或者,您可以使用最新版本的 Blender 3.6 和 VRM 插件将当前文件复制 "
+ "打开并保存后,将在内部创建数据以进行自动迁移\n"
+ "以便可以在Blender 4.2 或更高版本"
+ "不会丢失材质设置\n"
+ "可能受影响的材质如下。",
}

0 comments on commit ff45476

Please sign in to comment.