Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Duroure <julien.duroure@gmail.com>2019-02-01 21:22:32 +0300
committerJulien Duroure <julien.duroure@gmail.com>2019-02-01 21:22:32 +0300
commit787a1b8f1ea8926c587e36e37e3416d3fa6d0e63 (patch)
tree2f459464588fac8ab9b2bca2e428d6ab8bb7d5bc /io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py
parentd5a570ddb9d5c67ceec6fbd5bc684d1dd89f54e4 (diff)
glTF importer: Fix alpha usage in unlit material
Using emission node + is camera ray
Diffstat (limited to 'io_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py')
-rwxr-xr-xio_scene_gltf2/blender/imp/gltf2_blender_pbrMetallicRoughness.py34
1 files changed, 30 insertions, 4 deletions
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])