2016-06-22 12:21:15 +02:00
|
|
|
import bpy
|
|
|
|
from bpy.types import NodeTree, Node, NodeSocket
|
|
|
|
from bpy.props import *
|
2016-10-19 13:28:06 +02:00
|
|
|
import nodes
|
2016-06-22 12:21:15 +02:00
|
|
|
|
|
|
|
def parse_defs(node_group):
|
2016-10-19 13:28:06 +02:00
|
|
|
rn = nodes.get_node_by_type(node_group, 'COMPOSITE')
|
2016-09-28 00:00:59 +02:00
|
|
|
if rn == None:
|
|
|
|
return ''
|
2016-08-15 23:45:03 +02:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
parse_defs.defs = []
|
2016-10-19 13:28:06 +02:00
|
|
|
build_node(node_group, nodes.get_input_node(node_group, rn, 0))
|
2016-08-15 23:45:03 +02:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
# Always include tonemap for now
|
|
|
|
add_def('_CompoTonemap')
|
2016-08-15 23:45:03 +02:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
# To string
|
|
|
|
s = ''
|
|
|
|
for d in parse_defs.defs:
|
|
|
|
s += d
|
|
|
|
return s
|
2016-08-15 23:45:03 +02:00
|
|
|
|
|
|
|
def add_def(s):
|
2016-09-28 00:00:59 +02:00
|
|
|
# Only push unique
|
|
|
|
for d in parse_defs.defs:
|
|
|
|
if d == s:
|
|
|
|
return
|
|
|
|
parse_defs.defs.append(s)
|
2016-08-15 23:45:03 +02:00
|
|
|
|
|
|
|
def build_node(node_group, node):
|
2016-09-28 00:00:59 +02:00
|
|
|
# Inputs to follow
|
|
|
|
inps = []
|
2016-08-15 23:45:03 +02:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
if node.type == 'RGBTOBW':
|
|
|
|
add_def('_CompoBW')
|
|
|
|
inps.append(0)
|
|
|
|
elif node.type == 'TONEMAP':
|
|
|
|
add_def('_CompoTonemap')
|
|
|
|
inps.append(0)
|
|
|
|
elif node.type == 'LENSDIST':
|
|
|
|
add_def('_CompoFishEye')
|
|
|
|
inps.append(0)
|
|
|
|
elif node.type == 'GLARE':
|
|
|
|
add_def('_CompoGlare')
|
|
|
|
inps.append(0)
|
|
|
|
elif node.type == 'ELLIPSEMASK':
|
|
|
|
add_def('_CompoVignette')
|
|
|
|
elif node.type == 'MIX_RGB':
|
|
|
|
inps.append(1)
|
|
|
|
inps.append(2)
|
|
|
|
elif node.type == 'BLUR':
|
|
|
|
inps.append(0)
|
2016-08-15 23:45:03 +02:00
|
|
|
|
2016-09-28 00:00:59 +02:00
|
|
|
# Build next stage
|
|
|
|
for inp in inps:
|
|
|
|
if node.inputs[inp].is_linked:
|
2016-10-19 13:28:06 +02:00
|
|
|
next_node = nodes.get_input_node(node_group, node, inp)
|
2016-09-28 00:00:59 +02:00
|
|
|
build_node(node_group, next_node)
|