[Bf-extensions-cvs] [787a1b8f] master: glTF importer: Fix alpha usage in unlit material
Julien Duroure
noreply at git.blender.org
Fri Feb 1 19:23:09 CET 2019
Commit: 787a1b8f1ea8926c587e36e37e3416d3fa6d0e63
Author: Julien Duroure
Date: Fri Feb 1 19:22:32 2019 +0100
Branches: master
https://developer.blender.org/rBA787a1b8f1ea8926c587e36e37e3416d3fa6d0e63
glTF importer: Fix alpha usage in unlit material
Using emission node + is camera ray
===================================================================
M io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
===================================================================
diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
index cfa6b83c..72a75880 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
@@ -55,8 +55,8 @@ class BlenderPbr():
main_node = node_tree.nodes.new('ShaderNodeBsdfPrincipled')
main_node.location = 0, 0
elif nodetype == "unlit":
- main_node = node_tree.nodes.new('ShaderNodeBackground')
- main_node.location = 0, 0
+ main_node = node_tree.nodes.new('ShaderNodeEmission')
+ main_node.location = 750, -300
if pypbr.color_type == gltf.SIMPLE:
@@ -297,6 +297,32 @@ class BlenderPbr():
node_tree.links.new(metallic_text.inputs[0], metallic_mapping.outputs[0])
# link node to output
-
- node_tree.links.new(output_node.inputs[0], main_node.outputs[0])
+ if nodetype == 'principled':
+ node_tree.links.new(output_node.inputs[0], main_node.outputs[0])
+ elif nodetype == 'unlit':
+ mix = node_tree.nodes.new('ShaderNodeMixShader')
+ mix.location = 1000, 0
+ path = node_tree.nodes.new('ShaderNodeLightPath')
+ path.location = 500, 300
+ if pypbr.color_type != gltf.SIMPLE:
+ math = node_tree.nodes.new('ShaderNodeMath')
+ math.location = 750, 200
+ math.operation = 'MULTIPLY'
+
+ # Set material alpha mode to blend
+ # This is needed for Eevee
+ material.blend_method = 'HASHED' # TODO check best result in eevee
+
+ transparent = node_tree.nodes.new('ShaderNodeBsdfTransparent')
+ transparent.location = 750, 0
+
+ node_tree.links.new(output_node.inputs[0], mix.outputs[0])
+ node_tree.links.new(mix.inputs[2], main_node.outputs[0])
+ node_tree.links.new(mix.inputs[1], transparent.outputs[0])
+ if pypbr.color_type != gltf.SIMPLE:
+ node_tree.links.new(math.inputs[0], path.outputs[0])
+ node_tree.links.new(math.inputs[1], text_node.outputs[1])
+ node_tree.links.new(mix.inputs[0], math.outputs[0])
+ else:
+ node_tree.links.new(mix.inputs[0], path.outputs[0])
More information about the Bf-extensions-cvs
mailing list