2016-12-09 02:08:01 +01:00
|
|
|
import bpy
|
|
|
|
import nodes_renderpath
|
|
|
|
|
|
|
|
group = None
|
|
|
|
nodes = None
|
|
|
|
links = None
|
|
|
|
|
|
|
|
def make_renderer(cam):
|
|
|
|
global group
|
|
|
|
global nodes
|
|
|
|
global links
|
|
|
|
|
|
|
|
if cam.rp_renderer == 'Forward':
|
2016-12-23 02:51:24 +01:00
|
|
|
nodes_renderpath.load_library('forward_path', 'armory_default')
|
2016-12-09 02:08:01 +01:00
|
|
|
group = bpy.data.node_groups['armory_default']
|
|
|
|
nodes = group.nodes
|
|
|
|
links = group.links
|
|
|
|
make_forward(cam)
|
|
|
|
else: # Deferred
|
2016-12-23 02:51:24 +01:00
|
|
|
nodes_renderpath.load_library('deferred_path', 'armory_default')
|
2016-12-09 02:08:01 +01:00
|
|
|
group = bpy.data.node_groups['armory_default']
|
|
|
|
nodes = group.nodes
|
|
|
|
links = group.links
|
|
|
|
make_deferred(cam)
|
|
|
|
|
|
|
|
def relink(start_node, next_node):
|
2017-01-31 17:58:30 +01:00
|
|
|
if len(nodes[start_node].inputs[0].links) > 0:
|
|
|
|
n = nodes[start_node].inputs[0].links[0].from_node
|
|
|
|
l = n.outputs[0].links[0]
|
|
|
|
links.remove(l)
|
|
|
|
links.new(n.outputs[0], nodes[next_node].inputs[0])
|
2016-12-09 02:08:01 +01:00
|
|
|
|
|
|
|
def make_forward(cam):
|
|
|
|
|
2016-12-23 02:51:24 +01:00
|
|
|
nodes['Begin'].inputs[1].default_value = cam.rp_hdr
|
|
|
|
nodes['Screen'].inputs[0].default_value = int(cam.rp_supersampling)
|
2016-12-09 02:08:01 +01:00
|
|
|
|
|
|
|
if cam.rp_shadowmap != 'None':
|
|
|
|
n = nodes['Shadow Map']
|
|
|
|
n.inputs[1].default_value = n.inputs[2].default_value = int(cam.rp_shadowmap)
|
2016-12-23 02:51:24 +01:00
|
|
|
else:
|
|
|
|
l = nodes['Begin'].outputs[0].links[0]
|
|
|
|
links.remove(l)
|
|
|
|
links.new(nodes['Begin'].outputs[0], nodes['Set Target Mesh'].inputs[0])
|
2017-01-23 00:48:59 +01:00
|
|
|
relink('Bind Target Mesh SM', 'Draw Meshes Mesh') # No shadowmap bind
|
|
|
|
relink('Bind Target Transluc SM', 'Draw Meshes Transluc')
|
2016-12-09 02:08:01 +01:00
|
|
|
|
|
|
|
if not cam.rp_worldnodes:
|
2016-12-23 02:51:24 +01:00
|
|
|
relink('Draw World', 'Set Target Accum')
|
2017-01-30 12:02:40 +01:00
|
|
|
nodes['Clear Target Mesh'].inputs[1].default_value = True
|
|
|
|
|
|
|
|
if not cam.rp_render_to_texture:
|
|
|
|
links.new(nodes['Framebuffer'].outputs[0], nodes['Set Target Mesh'].inputs[1])
|
|
|
|
if cam.rp_worldnodes:
|
|
|
|
l = nodes['Draw World'].outputs[0].links[0]
|
|
|
|
else:
|
|
|
|
l = nodes['Draw Meshes Mesh'].outputs[0].links[0]
|
|
|
|
links.remove(l)
|
2016-12-09 02:08:01 +01:00
|
|
|
|
|
|
|
if not cam.rp_translucency:
|
2016-12-23 02:51:24 +01:00
|
|
|
relink('Set Target Accum', 'Draw Compositor + FXAA')
|
|
|
|
|
2017-01-30 12:02:40 +01:00
|
|
|
last_node = 'Draw Compositor + FXAA'
|
|
|
|
if cam.rp_antialiasing == 'SMAA':
|
|
|
|
pass
|
|
|
|
elif cam.rp_antialiasing == 'TAA':
|
|
|
|
pass
|
|
|
|
elif cam.rp_antialiasing == 'FXAA':
|
|
|
|
pass
|
|
|
|
elif cam.rp_antialiasing == 'None':
|
|
|
|
last_node = 'Draw Compositor'
|
|
|
|
relink('Draw Compositor + FXAA', 'Draw Compositor')
|
|
|
|
|
2016-12-23 02:51:24 +01:00
|
|
|
if cam.rp_overlays:
|
2017-01-30 12:02:40 +01:00
|
|
|
links.new(last_node.outputs[0], nodes['Clear Target Overlay'].inputs[0])
|
2016-12-09 02:08:01 +01:00
|
|
|
|
|
|
|
def make_deferred(cam):
|
|
|
|
|
2016-12-23 02:51:24 +01:00
|
|
|
nodes['Begin'].inputs[1].default_value = cam.rp_hdr
|
|
|
|
nodes['Screen'].inputs[0].default_value = int(cam.rp_supersampling)
|
2016-12-09 02:08:01 +01:00
|
|
|
|
|
|
|
if cam.rp_shadowmap != 'None':
|
|
|
|
n = nodes['Shadow Map']
|
|
|
|
n.inputs[1].default_value = n.inputs[2].default_value = int(cam.rp_shadowmap)
|
2016-12-23 02:51:24 +01:00
|
|
|
else:
|
|
|
|
l = nodes['Loop Lamps'].outputs[1].links[0]
|
|
|
|
links.remove(l)
|
|
|
|
links.new(nodes['Loop Lamps'].outputs[1], nodes['Deferred Light'].inputs[0])
|
2017-01-23 00:48:59 +01:00
|
|
|
l = nodes['Deferred Light'].inputs[3].links[0] # No shadowmap bind
|
|
|
|
links.remove(l)
|
|
|
|
l = nodes['Volumetric Light'].inputs[6].links[0]
|
|
|
|
links.remove(l)
|
|
|
|
relink('Bind Target Transluc SM', 'Draw Meshes Transluc')
|
2016-12-09 02:08:01 +01:00
|
|
|
|
2016-12-23 02:51:24 +01:00
|
|
|
# if not cam.rp_decals:
|
|
|
|
# relink('Set Target.005', 'SSAO')
|
2016-12-09 02:08:01 +01:00
|
|
|
|
|
|
|
if not cam.rp_ssao:
|
|
|
|
relink('SSAO', 'Deferred Indirect')
|
|
|
|
l = nodes['Deferred Indirect'].inputs[3].links[0]
|
|
|
|
links.remove(l)
|
|
|
|
|
2016-12-23 02:51:24 +01:00
|
|
|
if not cam.rp_worldnodes:
|
|
|
|
relink('Draw World', 'Set Target Accum')
|
|
|
|
|
|
|
|
if not cam.rp_translucency:
|
|
|
|
relink('Set Target Accum', 'Bloom')
|
|
|
|
|
2017-01-08 13:21:54 +01:00
|
|
|
# if not cam.rp_bloom:
|
|
|
|
relink('Bloom', 'SSR')
|
2016-12-09 02:08:01 +01:00
|
|
|
|
|
|
|
if not cam.rp_ssr:
|
|
|
|
relink('SSR', 'Draw Compositor')
|
|
|
|
|
2017-02-15 12:42:40 +01:00
|
|
|
last_node = 'Draw Compositor'
|
2016-12-23 02:51:24 +01:00
|
|
|
if not cam.rp_compositornodes:
|
2016-12-09 02:08:01 +01:00
|
|
|
pass
|
|
|
|
|
2017-02-15 12:42:40 +01:00
|
|
|
if cam.rp_overlays:
|
|
|
|
links.new(nodes[last_node].outputs[0], nodes['Clear Target Overlay'].inputs[0])
|
|
|
|
last_node = 'Draw Meshes Overlay'
|
|
|
|
links.new(nodes[last_node].outputs[0], nodes['SMAA'].inputs[0])
|
|
|
|
|
2016-12-09 02:08:01 +01:00
|
|
|
if cam.rp_antialiasing == 'SMAA':
|
2016-12-23 02:51:24 +01:00
|
|
|
last_node = 'SMAA'
|
|
|
|
elif cam.rp_antialiasing == 'TAA':
|
|
|
|
last_node = 'Copy'
|
|
|
|
links.new(nodes['SMAA'].outputs[0], nodes['TAA'].inputs[0])
|
|
|
|
links.new(nodes['Reroute.019'].outputs[0], nodes['SMAA'].inputs[5])
|
|
|
|
links.new(nodes['gbuffer2'].outputs[0], nodes['GBuffer'].inputs[2])
|
|
|
|
links.new(nodes['Reroute.014'].outputs[0], nodes['SMAA'].inputs[1])
|
|
|
|
elif cam.rp_antialiasing == 'FXAA':
|
|
|
|
last_node = 'FXAA'
|
2016-12-09 02:08:01 +01:00
|
|
|
relink('SMAA', 'FXAA')
|
2016-12-23 02:51:24 +01:00
|
|
|
elif cam.rp_antialiasing == 'None':
|
|
|
|
last_node = 'Draw Compositor'
|
|
|
|
l = nodes['Draw Compositor'].outputs[0].links[0]
|
2016-12-09 02:08:01 +01:00
|
|
|
links.remove(l)
|
2016-12-23 02:51:24 +01:00
|
|
|
links.new(nodes['Framebuffer'].outputs[0], nodes['Draw Compositor'].inputs[1])
|