[Bf-extensions-cvs] [78fe8ec0] master: glTF exporter: Add export support for Emission socket of Principled BSDF node

Julien Duroure noreply at git.blender.org
Wed Nov 13 22:04:01 CET 2019


Commit: 78fe8ec049fa3242bbbc2db5faed297e36374993
Author: Julien Duroure
Date:   Wed Nov 13 22:03:44 2019 +0100
Branches: master
https://developer.blender.org/rBA78fe8ec049fa3242bbbc2db5faed297e36374993

glTF exporter: Add export support for Emission socket of Principled BSDF node

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_get.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index cddc50fd..3a048afe 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,7 @@
 bl_info = {
     'name': 'glTF 2.0 format',
     'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
-    "version": (1, 1, 5),
+    "version": (1, 1, 6),
     'blender': (2, 81, 6),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_get.py b/io_scene_gltf2/blender/exp/gltf2_blender_get.py
index a16811d8..fd7d4222 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_get.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_get.py
@@ -55,8 +55,17 @@ def get_socket_or_texture_slot(blender_material: bpy.types.Material, name: str):
         #i = [input for input in blender_material.node_tree.inputs]
         #o = [output for output in blender_material.node_tree.outputs]
         if name == "Emissive":
+            # Check for a dedicated Emission node first, it must supersede the newer built-in one
+            # because the newer one is always present in all Principled BSDF materials.
             type = bpy.types.ShaderNodeEmission
             name = "Color"
+            nodes = [n for n in blender_material.node_tree.nodes if isinstance(n, type)]
+            inputs = sum([[input for input in node.inputs if input.name == name] for node in nodes], [])
+            if inputs:
+                return inputs[0]
+            # If a dedicated Emission node was not found, fall back to the Principled BSDF Emission socket.
+            name = "Emission"
+            type = bpy.types.ShaderNodeBsdfPrincipled
         elif name == "Background":
             type = bpy.types.ShaderNodeBackground
             name = "Color"



More information about the Bf-extensions-cvs mailing list