forked from blender/blender-addons
BLEN-350: Fix error with Add shader node #3
@ -31,6 +31,10 @@ def enabled(val):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def get_node_type(node):
|
||||||
|
return node.getType() if isinstance(node, mx.Node) else node.nodedef.getType()
|
||||||
|
|
||||||
|
|
||||||
class ShaderNodeBsdfPrincipled(NodeParser):
|
class ShaderNodeBsdfPrincipled(NodeParser):
|
||||||
nodegraph_path = ""
|
nodegraph_path = ""
|
||||||
|
|
||||||
@ -228,29 +232,27 @@ class ShaderNodeMixShader(NodeParser):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if shader2 is None:
|
if shader2 is None:
|
||||||
|
mix = self.create_node('mix', get_node_type(shader1).lower(), prefix='PBR', inputs={
|
||||||
mix = self.create_node('mix', shader1.getType().lower(), prefix='PBR', inputs={
|
|
||||||
'fg': shader1,
|
'fg': shader1,
|
||||||
'mix': factor
|
'mix': factor
|
||||||
})
|
})
|
||||||
|
|
||||||
if shader1 is None:
|
if shader1 is None:
|
||||||
mix = self.create_node('mix', shader2.getType().lower(), prefix='PBR', inputs={
|
mix = self.create_node('mix', get_node_type(shader2).lower(), prefix='PBR', inputs={
|
||||||
'bg': shader2,
|
'bg': shader2,
|
||||||
'mix': factor
|
'mix': factor
|
||||||
})
|
})
|
||||||
|
|
||||||
if shader1 is not None and shader2 is not None:
|
if shader1 is not None and shader2 is not None:
|
||||||
shader1_type = shader1.getType().lower()
|
shader1_type = get_node_type(shader1)
|
||||||
shader2_type = shader2.getType().lower()
|
shader2_type = get_node_type(shader2)
|
||||||
|
|
||||||
if shader1_type != shader2_type:
|
if shader1_type != shader2_type:
|
||||||
log.warn(f'Types of input shaders must be the same.'
|
log.warn(f'Types of input shaders must be the same.'
|
||||||
f' First shader type: {shader1_type}, second shader type: {shader2_type}')
|
f' First shader type: {shader1_type}, second shader type: {shader2_type}')
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
mix = self.create_node('mix', shader1_type, prefix='PBR', inputs={
|
mix = self.create_node('mix', shader1_type.lower(), prefix='PBR', inputs={
|
||||||
'fg': shader1,
|
'fg': shader1,
|
||||||
'bg': shader2,
|
'bg': shader2,
|
||||||
'mix': factor
|
'mix': factor
|
||||||
@ -260,7 +262,7 @@ class ShaderNodeMixShader(NodeParser):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
result = self.create_node('surface', 'surfaceshader', prefix='PBR', inputs={
|
result = self.create_node('surface', 'surfaceshader', prefix='PBR', inputs={
|
||||||
'bsdf': mix,
|
mix.nodedef.getType().lower(): mix,
|
||||||
'opacity': 1.0
|
'opacity': 1.0
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -280,26 +282,25 @@ class ShaderNodeAddShader(NodeParser):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
if shader2 is None:
|
if shader2 is None:
|
||||||
add = self.create_node('add', shader1.getType().lower(), prefix='PBR', inputs={
|
add = self.create_node('add', get_node_type(shader1).lower(), prefix='PBR', inputs={
|
||||||
'in1': shader1
|
'in1': shader1
|
||||||
})
|
})
|
||||||
|
|
||||||
if shader1 is None:
|
if shader1 is None:
|
||||||
add = self.create_node('add', shader2.getType().lower(), prefix='PBR', inputs={
|
add = self.create_node('add', get_node_type(shader2).lower(), prefix='PBR', inputs={
|
||||||
'in2': shader2
|
'in2': shader2
|
||||||
})
|
})
|
||||||
|
|
||||||
if shader1 is not None and shader2 is not None:
|
if shader1 is not None and shader2 is not None:
|
||||||
shader1_type = shader1.getType().lower()
|
shader1_type = get_node_type(shader1)
|
||||||
shader2_type = shader2.getType().lower()
|
shader2_type = get_node_type(shader2)
|
||||||
|
|
||||||
if shader1_type != shader2_type:
|
if shader1_type != shader2_type:
|
||||||
log.warn(f'Types of input shaders must be the same.'
|
log.warn(f'Types of input shaders must be the same.'
|
||||||
f' First shader type: {shader1_type}, second shader type: {shader2_type}')
|
f' First shader type: {shader1_type}, second shader type: {shader2_type}')
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
add = self.create_node('add', shader1_type, prefix='PBR', inputs={
|
add = self.create_node('add', shader1_type.lower(), prefix='PBR', inputs={
|
||||||
'in1': shader1,
|
'in1': shader1,
|
||||||
'in2': shader2
|
'in2': shader2
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user