armory/blender/arm/make_renderer.py

605 lines
22 KiB
Python
Raw Normal View History

2016-12-09 02:08:01 +01:00
import bpy
2017-03-15 12:30:14 +01:00
import arm.nodes_renderpath as nodes_renderpath
import arm.utils
2017-08-21 12:17:55 +02:00
import arm.assets as assets
2016-12-09 02:08:01 +01:00
group = None
nodes = None
links = None
2017-08-19 12:10:06 +02:00
updating_preset = False
2017-08-21 20:16:06 +02:00
first_build = True
2017-08-19 12:10:06 +02:00
2017-08-21 20:16:06 +02:00
def check_default():
global first_build
2017-08-19 12:10:06 +02:00
wrd = bpy.data.worlds['Arm']
2017-08-21 20:16:06 +02:00
if len(wrd.arm_rplist) == 0:
wrd.arm_rplist.add()
wrd.arm_rplist_index = 0
first_build = True
if first_build == True:
make_renderer(arm.utils.get_rp())
first_build = False
2017-08-19 12:10:06 +02:00
2017-08-21 20:16:06 +02:00
def set_preset(self, context, preset):
global updating_preset
rpdat = arm.utils.get_rp()
2017-08-19 12:10:06 +02:00
updating_preset = True
if preset == 'Low':
2017-08-21 20:16:06 +02:00
rpdat.rp_renderer = 'Forward'
2017-10-01 19:09:09 +02:00
rpdat.arm_material_model = 'Full'
2017-08-21 20:16:06 +02:00
rpdat.rp_shadowmap = '1024'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
2017-09-29 01:18:57 +02:00
rpdat.rp_blending_state = 'Off'
2017-08-21 20:16:06 +02:00
rpdat.rp_hdr = False
2017-08-22 15:57:49 +02:00
rpdat.rp_background = 'World'
2017-08-21 20:16:06 +02:00
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_voxelgi = False
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'None'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssao = False
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
2017-09-07 11:44:45 +02:00
rpdat.arm_rp_resolution = 'Display'
2017-09-08 16:43:48 +02:00
rpdat.arm_texture_filter = 'Anisotropic'
2017-08-19 12:10:06 +02:00
elif preset == 'Forward':
2017-08-21 20:16:06 +02:00
rpdat.rp_renderer = 'Forward'
2017-10-01 19:09:09 +02:00
rpdat.arm_material_model = 'Full'
2017-08-21 20:16:06 +02:00
rpdat.rp_shadowmap = '2048'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
2017-09-29 01:18:57 +02:00
rpdat.rp_blending_state = 'Off'
2017-08-21 20:16:06 +02:00
rpdat.rp_hdr = True
2017-08-22 15:57:49 +02:00
rpdat.rp_background = 'World'
2017-08-21 20:16:06 +02:00
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_voxelgi = False
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'SMAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssao = True
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
2017-09-07 11:44:45 +02:00
rpdat.arm_rp_resolution = 'Display'
2017-09-08 16:43:48 +02:00
rpdat.arm_texture_filter = 'Anisotropic'
2017-08-19 12:10:06 +02:00
elif preset == 'Deferred':
2017-08-21 20:16:06 +02:00
rpdat.rp_renderer = 'Deferred'
2017-10-01 19:09:09 +02:00
rpdat.arm_material_model = 'Full'
2017-08-21 20:16:06 +02:00
rpdat.rp_shadowmap = '2048'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
2017-09-29 01:18:57 +02:00
rpdat.rp_blending_state = 'Off'
2017-08-21 20:16:06 +02:00
rpdat.rp_hdr = True
2017-08-22 15:57:49 +02:00
rpdat.rp_background = 'World'
2017-08-21 20:16:06 +02:00
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_voxelgi = False
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'FXAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssao = True
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
2017-09-07 11:44:45 +02:00
rpdat.arm_rp_resolution = 'Display'
2017-09-08 16:43:48 +02:00
rpdat.arm_texture_filter = 'Anisotropic'
2017-08-19 12:10:06 +02:00
elif preset == 'Max':
2017-08-21 20:16:06 +02:00
rpdat.rp_renderer = 'Deferred'
2017-10-01 19:09:09 +02:00
rpdat.arm_material_model = 'Full'
2017-08-21 20:16:06 +02:00
rpdat.rp_shadowmap = '4096'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
2017-09-29 01:18:57 +02:00
rpdat.rp_blending_state = 'Off'
2017-08-21 20:16:06 +02:00
rpdat.rp_hdr = True
2017-08-22 15:57:49 +02:00
rpdat.rp_background = 'World'
2017-08-21 20:16:06 +02:00
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_voxelgi = False
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'TAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssao = True
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
2017-09-07 11:44:45 +02:00
rpdat.arm_rp_resolution = 'Display'
2017-09-08 16:43:48 +02:00
rpdat.arm_texture_filter = 'Anisotropic'
2017-08-19 12:10:06 +02:00
elif preset == 'Render Capture':
2017-08-21 20:16:06 +02:00
rpdat.rp_renderer = 'Deferred'
rpdat.rp_shadowmap = '8192'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
2017-09-29 01:18:57 +02:00
rpdat.rp_blending_state = 'Off'
2017-08-21 20:16:06 +02:00
rpdat.rp_hdr = True
2017-08-22 15:57:49 +02:00
rpdat.rp_background = 'World'
2017-08-21 20:16:06 +02:00
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_voxelgi = True
rpdat.rp_voxelgi_resolution = '256'
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '2'
rpdat.rp_antialiasing = 'TAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssao = True
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = True
rpdat.rp_motionblur = 'None'
2017-09-07 11:44:45 +02:00
rpdat.arm_rp_resolution = 'Display'
2017-08-21 20:16:06 +02:00
rpdat.arm_material_model = 'Cycles'
rpdat.arm_pcss_state = 'On'
2017-09-08 16:43:48 +02:00
rpdat.arm_texture_filter = 'Anisotropic'
2017-08-19 12:10:06 +02:00
elif preset == 'Deferred Plus':
2017-08-21 20:16:06 +02:00
rpdat.rp_renderer = 'Deferred Plus'
2017-10-01 19:09:09 +02:00
rpdat.arm_material_model = 'Full'
2017-08-21 20:16:06 +02:00
rpdat.rp_shadowmap = '4096'
rpdat.rp_translucency_state = 'Auto'
rpdat.rp_overlays_state = 'Auto'
rpdat.rp_decals_state = 'Auto'
rpdat.rp_sss_state = 'Auto'
2017-09-29 01:18:57 +02:00
rpdat.rp_blending_state = 'Off'
2017-08-21 20:16:06 +02:00
rpdat.rp_hdr = True
2017-08-22 15:57:49 +02:00
rpdat.rp_background = 'World'
2017-08-21 20:16:06 +02:00
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_voxelgi = False
rpdat.rp_render_to_texture = True
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'TAA'
rpdat.rp_compositornodes = True
rpdat.rp_volumetriclight = False
rpdat.rp_ssao = True
rpdat.rp_ssr = True
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
2017-09-07 11:44:45 +02:00
rpdat.arm_rp_resolution = 'Display'
2017-09-08 16:43:48 +02:00
rpdat.arm_texture_filter = 'Anisotropic'
2017-08-19 12:10:06 +02:00
elif preset == 'VR Low':
2017-08-21 20:16:06 +02:00
rpdat.rp_renderer = 'Forward'
2017-10-01 19:09:09 +02:00
rpdat.arm_material_model = 'Mobile'
2017-08-21 20:16:06 +02:00
rpdat.rp_shadowmap = '1024'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
2017-09-29 01:18:57 +02:00
rpdat.rp_blending_state = 'Off'
2017-08-21 20:16:06 +02:00
rpdat.rp_hdr = False
2017-08-22 15:57:49 +02:00
rpdat.rp_background = 'World'
2017-08-21 20:16:06 +02:00
rpdat.rp_stereo = True
rpdat.rp_greasepencil = False
rpdat.rp_voxelgi = False
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'None'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssao = False
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
2017-09-07 11:44:45 +02:00
rpdat.arm_rp_resolution = 'Display'
2017-09-08 16:43:48 +02:00
rpdat.arm_texture_filter = 'Point'
2017-08-19 12:10:06 +02:00
elif preset == 'Mobile Low':
2017-08-21 20:16:06 +02:00
rpdat.rp_renderer = 'Forward'
2017-10-01 19:09:09 +02:00
rpdat.arm_material_model = 'Mobile'
2017-08-21 20:16:06 +02:00
rpdat.rp_shadowmap = '1024'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
2017-09-29 01:18:57 +02:00
rpdat.rp_blending_state = 'Off'
2017-08-21 20:16:06 +02:00
rpdat.rp_hdr = False
2017-09-06 13:28:59 +02:00
rpdat.rp_background = 'Clear'
2017-08-21 20:16:06 +02:00
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_voxelgi = False
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'None'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssao = False
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
2017-09-07 11:44:45 +02:00
rpdat.arm_rp_resolution = 'Display'
2017-09-08 16:43:48 +02:00
rpdat.arm_texture_filter = 'Point'
2017-08-19 12:10:06 +02:00
elif preset == 'Grease Pencil':
2017-08-21 20:16:06 +02:00
rpdat.rp_renderer = 'Forward'
2017-10-01 19:42:47 +02:00
rpdat.arm_material_model = 'Solid'
2017-08-21 20:16:06 +02:00
rpdat.rp_shadowmap = 'None'
rpdat.rp_translucency_state = 'Off'
rpdat.rp_overlays_state = 'Off'
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
2017-09-29 01:18:57 +02:00
rpdat.rp_blending_state = 'Off'
2017-08-21 20:16:06 +02:00
rpdat.rp_hdr = False
2017-08-22 15:57:49 +02:00
rpdat.rp_background = 'World'
2017-08-21 20:16:06 +02:00
rpdat.rp_stereo = False
rpdat.rp_greasepencil = True
rpdat.rp_render_to_texture = False
rpdat.rp_supersampling = '1'
rpdat.rp_antialiasing = 'None'
rpdat.rp_compositornodes = False
rpdat.rp_volumetriclight = False
rpdat.rp_ssao = False
rpdat.rp_ssr = False
rpdat.rp_dfrs = False
rpdat.rp_dfao = False
rpdat.rp_dfgi = False
rpdat.rp_bloom = False
rpdat.rp_eyeadapt = False
rpdat.rp_rendercapture = False
rpdat.rp_motionblur = 'None'
2017-09-07 11:44:45 +02:00
rpdat.arm_rp_resolution = 'Display'
2017-09-08 16:43:48 +02:00
rpdat.arm_texture_filter = 'Anisotropic'
2017-08-19 12:10:06 +02:00
updating_preset = False
set_renderpath(self, context)
def set_renderpath(self, context):
global updating_preset
if updating_preset == True:
return
# assets.invalidate_compiled_data(self, context)
assets.invalidate_shader_cache(self, context)
2017-08-21 20:16:06 +02:00
make_renderer(arm.utils.get_rp())
2017-08-19 12:10:06 +02:00
2017-08-21 20:16:06 +02:00
def make_renderer(rpdat):
2016-12-09 02:08:01 +01:00
global group
global nodes
global links
2017-04-16 14:46:35 +02:00
if bpy.data.filepath.endswith('arm_data.blend'): # Prevent load in library itself
return
2017-08-21 20:16:06 +02:00
if rpdat.rp_renderer == 'Forward':
2017-03-15 12:30:14 +01:00
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
2017-08-21 20:16:06 +02:00
make_forward(rpdat)
elif rpdat.rp_renderer == 'Deferred':
2017-03-15 12:30:14 +01:00
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
2017-08-21 20:16:06 +02:00
make_deferred(rpdat)
elif rpdat.rp_renderer == 'Deferred Plus':
2017-03-23 13:18:13 +01:00
load_library('deferred_plus_path', 'armory_default')
group = bpy.data.node_groups['armory_default']
nodes = group.nodes
links = group.links
2017-08-21 20:16:06 +02:00
make_deferred_plus(rpdat)
2016-12-09 02:08:01 +01:00
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
2017-08-21 20:16:06 +02:00
def make_forward(rpdat):
2016-12-09 02:08:01 +01:00
2017-08-21 20:16:06 +02:00
nodes['Begin'].inputs[1].default_value = rpdat.rp_hdr
nodes['Screen'].inputs[0].default_value = int(rpdat.rp_supersampling)
2016-12-09 02:08:01 +01:00
2017-09-07 16:23:17 +02:00
if not rpdat.rp_hdr:
nodes['lbuf'].inputs[4].default_value = 'RGBA32'
2017-08-21 20:16:06 +02:00
if rpdat.rp_shadowmap != 'None':
2016-12-09 02:08:01 +01:00
n = nodes['Shadow Map']
2017-08-21 20:16:06 +02:00
n.inputs[1].default_value = n.inputs[2].default_value = int(rpdat.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
2017-08-21 20:16:06 +02:00
if rpdat.rp_stereo:
if rpdat.rp_shadowmap != 'None':
2017-04-16 14:46:35 +02:00
links.new(nodes['Bind Target Mesh SM'].outputs[0], nodes['Draw Stereo'].inputs[0])
else:
links.new(nodes['Clear Target Mesh'].outputs[0], nodes['Draw Stereo'].inputs[0])
links.new(nodes['Draw Stereo'].outputs[1], nodes['Draw Meshes Mesh'].inputs[0])
2017-08-21 20:16:06 +02:00
if rpdat.rp_greasepencil:
if rpdat.rp_shadowmap != 'None':
2017-05-18 23:40:10 +02:00
links.new(nodes['Bind Target Mesh SM'].outputs[0], nodes['Draw Grease Pencil'].inputs[0])
else:
links.new(nodes['Clear Target Mesh'].outputs[0], nodes['Draw Grease Pencil'].inputs[0])
links.new(nodes['Draw Grease Pencil'].outputs[0], nodes['Draw Meshes Mesh'].inputs[0])
2017-08-22 15:57:49 +02:00
if rpdat.rp_background != 'World':
2016-12-23 02:51:24 +01:00
relink('Draw World', 'Set Target Accum')
2017-08-22 15:57:49 +02:00
if rpdat.rp_background == 'Clear':
2017-05-20 19:07:15 +02:00
nodes['Clear Target Mesh'].inputs[1].default_value = True
2017-01-30 12:02:40 +01:00
2017-08-21 20:16:06 +02:00
if not rpdat.rp_render_to_texture:
2017-01-30 12:02:40 +01:00
links.new(nodes['Framebuffer'].outputs[0], nodes['Set Target Mesh'].inputs[1])
2017-08-22 15:57:49 +02:00
if rpdat.rp_background == 'World':
2017-01-30 12:02:40 +01:00
l = nodes['Draw World'].outputs[0].links[0]
2017-08-21 20:16:06 +02:00
elif rpdat.rp_greasepencil:
2017-05-18 23:40:10 +02:00
l = nodes['Draw Grease Pencil'].outputs[0].links[0]
2017-01-30 12:02:40 +01:00
else:
l = nodes['Draw Meshes Mesh'].outputs[0].links[0]
links.remove(l)
2016-12-09 02:08:01 +01:00
2017-08-21 20:16:06 +02:00
if not rpdat.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'
2017-08-21 20:16:06 +02:00
if rpdat.rp_antialiasing == 'SMAA':
2017-01-30 12:02:40 +01:00
pass
2017-08-21 20:16:06 +02:00
elif rpdat.rp_antialiasing == 'TAA':
2017-01-30 12:02:40 +01:00
pass
2017-08-21 20:16:06 +02:00
elif rpdat.rp_antialiasing == 'FXAA':
2017-01-30 12:02:40 +01:00
pass
2017-08-21 20:16:06 +02:00
elif rpdat.rp_antialiasing == 'None':
2017-01-30 12:02:40 +01:00
last_node = 'Draw Compositor'
relink('Draw Compositor + FXAA', 'Draw Compositor')
2017-08-21 20:16:06 +02:00
if rpdat.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
2017-09-07 16:23:17 +02:00
if not rpdat.rp_compositornodes:
relink(last_node, 'Copy')
2017-08-21 20:16:06 +02:00
def make_deferred(rpdat):
2016-12-09 02:08:01 +01:00
2017-08-21 20:16:06 +02:00
nodes['Begin'].inputs[1].default_value = rpdat.rp_hdr
nodes['Screen'].inputs[0].default_value = int(rpdat.rp_supersampling)
2016-12-09 02:08:01 +01:00
2017-08-21 20:16:06 +02:00
if rpdat.rp_voxelgi:
2017-05-20 19:07:15 +02:00
n = nodes['Image 3D Voxels']
2017-08-21 20:16:06 +02:00
# if rpdat.rp_voxelgi_hdr:
2017-05-20 19:07:15 +02:00
# n.inputs[4].default_value = 'RGBA64'
2017-03-29 14:32:44 +02:00
links.new(nodes['Begin'].outputs[0], nodes['Branch Function Voxelize'].inputs[0])
links.new(nodes['Merge Stages Voxelize'].outputs[0], nodes['Set Target Mesh'].inputs[0])
2017-08-21 20:16:06 +02:00
res = int(rpdat.rp_voxelgi_resolution)
2017-08-03 14:01:04 +02:00
n.inputs[1].default_value = res
n.inputs[2].default_value = res
n.inputs[3].default_value = res
2017-02-22 15:50:19 +01:00
n = nodes['Set Viewport Voxels']
2017-08-03 14:01:04 +02:00
n.inputs[1].default_value = res
n.inputs[2].default_value = res
2017-02-22 15:50:19 +01:00
links.new(nodes['Image 3D Voxels'].outputs[0], nodes['Deferred Indirect'].inputs[4])
2017-08-21 20:16:06 +02:00
if rpdat.arm_voxelgi_shadows or rpdat.arm_voxelgi_refraction:
2017-08-13 20:28:06 +02:00
links.new(nodes['Image 3D Voxels'].outputs[0], nodes['Deferred Light'].inputs[4])
links.new(nodes['Image 3D Voxels'].outputs[0], nodes['Deferred Light.001'].inputs[4])
2017-08-22 10:04:13 +02:00
elif rpdat.rp_voxelao:
n = nodes['Image 3D Voxels']
# n.inputs[4].default_value = 'R8'
links.new(nodes['Begin'].outputs[0], nodes['Branch Function Voxelize'].inputs[0])
links.new(nodes['Merge Stages Voxelize'].outputs[0], nodes['Set Target Mesh'].inputs[0])
res = int(rpdat.rp_voxelgi_resolution)
n.inputs[1].default_value = res
n.inputs[2].default_value = res
n.inputs[3].default_value = res
n = nodes['Set Viewport Voxels']
n.inputs[1].default_value = res
n.inputs[2].default_value = res
links.new(nodes['Image 3D Voxels'].outputs[0], nodes['Deferred Indirect'].inputs[4])
2017-02-22 15:50:19 +01:00
2017-08-21 20:16:06 +02:00
if rpdat.rp_shadowmap != 'None':
2016-12-09 02:08:01 +01:00
n = nodes['Shadow Map']
2017-08-21 20:16:06 +02:00
n.inputs[1].default_value = n.inputs[2].default_value = int(rpdat.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
2017-08-21 20:16:06 +02:00
if rpdat.rp_volumetriclight:
2017-05-22 15:55:34 +02:00
links.new(nodes['Deferred Light'].outputs[0], nodes['Volumetric Light'].inputs[0])
2017-08-21 20:16:06 +02:00
if not rpdat.rp_decals:
2017-05-24 11:04:15 +02:00
relink('Set Target Decal', 'SSAO')
2016-12-09 02:08:01 +01:00
2017-08-21 20:16:06 +02:00
if not rpdat.rp_ssao:
2016-12-09 02:08:01 +01:00
relink('SSAO', 'Deferred Indirect')
l = nodes['Deferred Indirect'].inputs[3].links[0]
links.remove(l)
2017-08-22 15:57:49 +02:00
if rpdat.rp_background != 'World':
2017-07-04 13:29:01 +02:00
relink('Draw World', 'Water')
2017-08-22 15:57:49 +02:00
if rpdat.rp_background == 'Clear':
2017-05-20 19:07:15 +02:00
nodes['Clear Target Mesh'].inputs[1].default_value = True
2016-12-23 02:51:24 +01:00
2017-08-21 20:16:06 +02:00
if not rpdat.rp_ocean:
2017-09-29 01:18:57 +02:00
relink('Water', 'Draw Meshes Blend')
if rpdat.rp_blending_state == 'Off':
relink('Draw Meshes Blend', 'Set Target Accum')
2017-07-04 13:29:01 +02:00
2017-08-21 20:16:06 +02:00
if not rpdat.rp_translucency:
2016-12-23 02:51:24 +01:00
relink('Set Target Accum', 'Bloom')
2017-08-21 20:16:06 +02:00
if not rpdat.rp_bloom:
2017-06-25 23:16:49 +02:00
relink('Bloom', 'SSS')
2017-05-23 15:01:56 +02:00
2017-08-21 20:16:06 +02:00
if not rpdat.rp_sss:
2017-05-23 15:01:56 +02:00
relink('SSS', 'SSR')
2016-12-09 02:08:01 +01:00
2017-08-21 20:16:06 +02:00
if not rpdat.rp_ssr:
2016-12-09 02:08:01 +01:00
relink('SSR', 'Draw Compositor')
2017-08-21 20:16:06 +02:00
if rpdat.arm_ssr_half_res:
2017-03-14 20:43:54 +01:00
links.new(nodes['ssra'].outputs[0], nodes['SSR'].inputs[2])
links.new(nodes['ssrb'].outputs[0], nodes['SSR'].inputs[3])
2017-02-15 12:42:40 +01:00
last_node = 'Draw Compositor'
2017-08-21 20:16:06 +02:00
if not rpdat.rp_compositornodes:
2016-12-09 02:08:01 +01:00
pass
2017-08-21 20:16:06 +02:00
if rpdat.rp_overlays:
2017-02-15 12:42:40 +01:00
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])
2017-08-21 20:16:06 +02:00
if rpdat.rp_antialiasing == 'SMAA':
2016-12-23 02:51:24 +01:00
last_node = 'SMAA'
2017-08-21 20:16:06 +02:00
elif rpdat.rp_antialiasing == 'TAA':
2016-12-23 02:51:24 +01:00
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])
2017-08-08 11:14:01 +02:00
# Clear velocity
2017-08-09 15:52:27 +02:00
relink('Set Target Mesh', 'Set Target Veloc')
2017-08-08 11:14:01 +02:00
links.new(nodes['Clear Target Veloc'].outputs[0], nodes['Set Target Mesh'].inputs[0])
2017-08-21 20:16:06 +02:00
elif rpdat.rp_antialiasing == 'FXAA':
2016-12-23 02:51:24 +01:00
last_node = 'FXAA'
2016-12-09 02:08:01 +01:00
relink('SMAA', 'FXAA')
2017-08-21 20:16:06 +02:00
elif rpdat.rp_antialiasing == 'None':
2016-12-23 02:51:24 +01:00
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])
2017-03-15 12:30:14 +01:00
2017-08-21 20:16:06 +02:00
if rpdat.rp_supersampling == '4':
2017-04-26 17:37:30 +02:00
links.new(nodes[last_node].outputs[0], nodes['SS Resolve'].inputs[0])
2017-06-26 15:37:10 +02:00
last_node = 'SS Resolve'
2017-08-21 20:16:06 +02:00
if rpdat.rp_antialiasing == 'SMAA':
2017-04-26 17:37:30 +02:00
links.new(nodes['Reroute.014'].outputs[0], nodes['SMAA'].inputs[1])
links.new(nodes['Reroute.014'].outputs[0], nodes['SS Resolve'].inputs[2])
2017-08-21 20:16:06 +02:00
elif rpdat.rp_antialiasing == 'TAA':
2017-04-26 17:37:30 +02:00
links.new(nodes['Reroute.008'].outputs[0], nodes['TAA'].inputs[1])
links.new(nodes['Reroute.008'].outputs[0], nodes['SS Resolve'].inputs[2])
2017-08-21 20:16:06 +02:00
elif rpdat.rp_antialiasing == 'FXAA':
2017-04-26 17:37:30 +02:00
links.new(nodes['Reroute.008'].outputs[0], nodes['FXAA'].inputs[1])
links.new(nodes['Reroute.008'].outputs[0], nodes['SS Resolve'].inputs[2])
2017-08-21 20:16:06 +02:00
elif rpdat.rp_antialiasing == 'None':
2017-04-26 17:37:30 +02:00
links.new(nodes['Reroute.008'].outputs[0], nodes['Draw Compositor'].inputs[1])
links.new(nodes['Reroute.008'].outputs[0], nodes['SS Resolve'].inputs[2])
2017-08-21 20:16:06 +02:00
if rpdat.rp_eyeadapt:
2017-08-13 22:50:08 +02:00
links.new(nodes[last_node].outputs[0], nodes['Histogram'].inputs[0])
links.new(nodes['histogram'].outputs[0], nodes['Draw Compositor'].inputs[5])
2017-08-21 20:16:06 +02:00
if rpdat.rp_rendercapture:
2017-06-26 15:37:10 +02:00
# links.new(nodes[last_node].outputs[0], nodes['CopyCapture'].inputs[0])
fb = nodes['Framebuffer']
cc = nodes['CopyCapture']
cn = nodes['Capture']
for l in fb.outputs[0].links:
if l.to_node != cc:
links.new(cn.outputs[0], l.to_socket)
2017-08-23 23:37:55 +02:00
wrd = bpy.data.worlds['Arm']
if wrd.rp_rendercapture_format == '8bit':
2017-07-01 13:55:35 +02:00
cn.inputs[4].default_value = 'RGBA32'
2017-08-23 23:37:55 +02:00
elif wrd.rp_rendercapture_format == '16bit':
2017-07-01 13:55:35 +02:00
cn.inputs[4].default_value = 'RGBA64'
2017-08-23 23:37:55 +02:00
elif wrd.rp_rendercapture_format == '32bit':
2017-07-01 13:55:35 +02:00
cn.inputs[4].default_value = 'RGBA128'
2017-06-26 15:37:10 +02:00
2017-08-21 20:16:06 +02:00
def make_deferred_plus(rpdat):
2017-03-23 13:18:13 +01:00
pass
2017-03-15 12:30:14 +01:00
def reload_blend_data():
2017-08-21 20:16:06 +02:00
global first_build
first_build = True
2017-07-09 19:44:19 +02:00
armory_pbr = bpy.data.node_groups.get('Armory PBR')
if armory_pbr != None and len(armory_pbr.inputs) == 14:
armory_pbr.name = 'Armory PBR Old'
armory_pbr = None
if armory_pbr == None:
2017-03-15 12:30:14 +01:00
load_library('Armory PBR')
def load_library(asset_name, rename=None):
2017-04-16 14:46:35 +02:00
if bpy.data.filepath.endswith('arm_data.blend'): # Prevent load in library itself
return
2017-03-15 12:30:14 +01:00
sdk_path = arm.utils.get_sdk_path()
2017-04-16 14:46:35 +02:00
data_path = sdk_path + '/armory/blender/data/arm_data.blend'
2017-03-15 12:30:14 +01:00
data_names = [asset_name]
# Remove old
if rename != None and rename in bpy.data.node_groups and asset_name != 'Armory PBR':
bpy.data.node_groups.remove(bpy.data.node_groups[rename], do_unlink=True)
# Import
data_refs = data_names.copy()
with bpy.data.libraries.load(data_path, link=False) as (data_from, data_to):
data_to.node_groups = data_refs
for ref in data_refs:
ref.use_fake_user = True
if rename != None:
ref.name = rename
def register():
reload_blend_data()
def unregister():
pass