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

This commit is contained in:
Julien Duroure 2019-11-13 22:03:44 +01:00
parent 6790f39ca6
commit 78fe8ec049
2 changed files with 10 additions and 1 deletions

View File

@ -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',

View File

@ -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"