glTF importer: Fix alpha usage in unlit material
Using emission node + is camera ray
This commit is contained in:
parent
d5a570ddb9
commit
787a1b8f1e
|
@ -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
|
||||
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'
|
||||
|
||||
node_tree.links.new(output_node.inputs[0], main_node.outputs[0])
|
||||
# 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])
|
||||
|
||||
|
|
Loading…
Reference in New Issue