From a39b20c912e6875dccb1a5a2bf657be33e0ec45b Mon Sep 17 00:00:00 2001 From: nonl4331 Date: Wed, 25 Dec 2024 18:31:44 +1100 Subject: [PATCH 1/2] Added Color support for Diffuse BSDF --- .../blender/exp/material/pbr_metallic_roughness.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/addons/io_scene_gltf2/blender/exp/material/pbr_metallic_roughness.py b/addons/io_scene_gltf2/blender/exp/material/pbr_metallic_roughness.py index da6f92a02..df9edebfd 100644 --- a/addons/io_scene_gltf2/blender/exp/material/pbr_metallic_roughness.py +++ b/addons/io_scene_gltf2/blender/exp/material/pbr_metallic_roughness.py @@ -24,6 +24,7 @@ has_image_node_from_socket, \ get_const_from_default_value_socket, \ get_socket, \ + get_node_socket, \ get_factor_from_socket, \ gather_alpha_info, \ gather_color_info @@ -96,6 +97,8 @@ def __gather_base_color_factor(blender_material, export_settings): if base_color_socket.socket is None: base_color_socket = get_socket_from_gltf_material_node( blender_material.node_tree, blender_material.use_nodes, "BaseColorFactor") + if base_color_socket.socket is None: + base_color_socket = get_node_socket(blender_material.node_tree, bpy.types.ShaderNodeBsdfDiffuse, "Color") if base_color_socket.socket is not None and isinstance(base_color_socket.socket, bpy.types.NodeSocket): if export_settings['gltf_image_format'] != "NONE": rgb_vc_info = gather_color_info(base_color_socket.to_node_nav()) @@ -144,6 +147,8 @@ def __gather_base_color_texture(blender_material, export_settings): if base_color_socket.socket is None: base_color_socket = get_socket_from_gltf_material_node( blender_material.node_tree, blender_material.use_nodes, "BaseColor") + if base_color_socket.socket is None: + base_color_socket = get_node_socket(blender_material.node_tree, bpy.types.ShaderNodeBsdfDiffuse, "Color") alpha_socket = get_socket(blender_material.node_tree, blender_material.use_nodes, "Alpha") From da7acc1cc3d1228f45e27a8e99e9d52b2e10bdcb Mon Sep 17 00:00:00 2001 From: nonl4331 Date: Wed, 25 Dec 2024 18:40:28 +1100 Subject: [PATCH 2/2] Added documentation for diffuse BSDF Color input --- docs/blender_docs/scene_gltf2.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/blender_docs/scene_gltf2.rst b/docs/blender_docs/scene_gltf2.rst index 5bcd2cced..5397bb691 100644 --- a/docs/blender_docs/scene_gltf2.rst +++ b/docs/blender_docs/scene_gltf2.rst @@ -119,9 +119,9 @@ The material export process handles the settings described below. Base Color ^^^^^^^^^^ -The glTF base color is determined by looking for a Base Color input on a Principled BSDF node. -If the input is unconnected, the input's default color (the color field next to the unconnected socket) -is used as the Base Color for the glTF material. +The glTF base color is determined by looking for a Base Color input on a Principled BSDF node +or a Color input on a Diffuse BSDF node. If the input is unconnected, the input's default color +(the color field next to the unconnected socket) is used as the Base Color for the glTF material. .. figure:: /images/addons_import-export_scene-gltf2_material-base-color-solid-green.png