pos = obj.matrix_world@mathutils.Vector((0.0, 0.0, 0.0, 1.0))
light_res.statements.append(Statement("position", *tuple(pos)))
- c = light.color
- e = light.energy
- light_res.statements.append(Statement("color", c.r*e, c.g*e, c.b*e))
+ c = light.color*light.energy
+ light_res.statements.append(Statement("color", *tuple(c)))
return light_res
import os
-def get_linked_node_and_socket(node_tree, socket):
- for l in node_tree.links:
- if socket==l.to_socket:
- return (l.from_node, l.from_socket)
- elif socket==l.from_socket:
- return (l.to_node, l.to_socket)
- return (None, None)
-
def check_group(node_tree, group, func):
+ from .util import get_linked_node_and_socket
+
output = group.node_tree.nodes["Group Output"]
from_node, _ = get_linked_node_and_socket(group.node_tree, output.inputs[0])
if from_node:
elif node.type!='COMBRGB':
return (None, None)
+ from .util import get_linked_node_and_socket
+
green, g_sock = get_linked_node_and_socket(node_tree, node.inputs["G"])
if not green or green.type!='MATH' or green.operation!='SUBTRACT':
return (None, None)
self.value = input_socket.default_value
if self.tex_keyword:
+ from .util import get_linked_node_and_socket
+
from_node, _ = get_linked_node_and_socket(node_tree, input_socket)
alpha_from = None
if from_node:
elif self.render_mode=='CUSTOM' and not self.shader:
raise Exception("Invalid configuration on material {}: No shader for custom rendering".format(self.name))
- out_node = None
- for n in material.node_tree.nodes:
- if n.type=='OUTPUT_MATERIAL':
- out_node = n
- break
-
+ out_node = next((n for n in material.node_tree.nodes if n.type=='OUTPUT_MATERIAL'), None)
if not out_node:
raise Exception("No output node found on material {}".format(self.name))
+ from .util import get_linked_node_and_socket
+
surface_node, _ = get_linked_node_and_socket(material.node_tree, out_node.inputs["Surface"])
if not surface_node:
if self.render_mode=='BUILTIN':
result.append(i)
seen.add(i)
return result
+
+def get_linked_node_and_socket(node_tree, socket):
+ for l in node_tree.links:
+ if socket==l.to_socket:
+ return (l.from_node, l.from_socket)
+ elif socket==l.from_socket:
+ return (l.to_node, l.to_socket)
+ return (None, None)