2017-02-07 14:55:49 +01:00
|
|
|
import bpy
|
2017-03-15 12:30:14 +01:00
|
|
|
import arm.utils
|
|
|
|
import arm.make_state as make_state
|
|
|
|
import arm.material.cycles as cycles
|
|
|
|
import arm.log as log
|
2016-12-19 01:25:22 +01:00
|
|
|
|
2017-02-09 22:52:47 +01:00
|
|
|
add_mesh_contexts = []
|
|
|
|
|
2016-12-19 01:25:22 +01:00
|
|
|
def disp_linked(output_node):
|
2017-01-14 16:32:10 +01:00
|
|
|
# Armory PBR with unlinked height socket
|
|
|
|
linked = output_node.inputs[2].is_linked
|
2017-03-15 12:30:14 +01:00
|
|
|
tess_enabled = arm.utils.tess_enabled(make_state.target)
|
2017-01-14 16:32:10 +01:00
|
|
|
if linked:
|
2016-12-19 01:25:22 +01:00
|
|
|
l = output_node.inputs[2].links[0]
|
|
|
|
if l.from_node.type == 'GROUP' and l.from_node.node_tree.name.startswith('Armory PBR') and l.from_node.inputs[10].is_linked == False:
|
|
|
|
return False
|
2017-01-14 16:32:10 +01:00
|
|
|
if linked and not tess_enabled:
|
|
|
|
log.warn('Tessellation not available on ' + make_state.target)
|
|
|
|
return tess_enabled and linked
|
2016-12-19 01:25:22 +01:00
|
|
|
|
|
|
|
def get_rpasses(material):
|
|
|
|
|
|
|
|
ar = []
|
|
|
|
|
2016-12-20 00:39:18 +01:00
|
|
|
# if material.depthpass:
|
|
|
|
# ar.append('depth')
|
2016-12-19 01:25:22 +01:00
|
|
|
|
2016-12-20 00:39:18 +01:00
|
|
|
# if material.decal:
|
|
|
|
# ar.append('decal')
|
2017-02-09 22:52:47 +01:00
|
|
|
|
2016-12-19 01:25:22 +01:00
|
|
|
if material.overlay:
|
|
|
|
ar.append('overlay')
|
|
|
|
elif is_transluc(material):
|
|
|
|
ar.append('translucent')
|
|
|
|
else:
|
|
|
|
ar.append('mesh')
|
2017-02-09 22:52:47 +01:00
|
|
|
for con in add_mesh_contexts:
|
|
|
|
ar.append(con)
|
2017-02-22 15:50:19 +01:00
|
|
|
if bpy.data.cameras[0].rp_voxelgi:
|
2017-02-18 20:18:38 +01:00
|
|
|
ar.append('voxel')
|
2017-05-20 19:07:15 +02:00
|
|
|
if bpy.data.worlds['Arm'].voxelgi_multibounce:
|
|
|
|
ar.append('voxelbounce')
|
2017-03-28 14:30:51 +02:00
|
|
|
if bpy.data.cameras[0].rp_renderer == 'Deferred Plus':
|
|
|
|
ar.append('rect')
|
2016-12-19 01:25:22 +01:00
|
|
|
|
2017-02-07 14:55:49 +01:00
|
|
|
shadows_enabled = False
|
|
|
|
for cam in bpy.data.cameras:
|
|
|
|
if cam.rp_shadowmap != 'None':
|
|
|
|
shadows_enabled = True
|
|
|
|
break
|
|
|
|
|
|
|
|
if material.cast_shadow and shadows_enabled and ('mesh' in ar or 'translucent' in ar):
|
2016-12-20 00:39:18 +01:00
|
|
|
ar.append('shadowmap')
|
2016-12-19 01:25:22 +01:00
|
|
|
|
|
|
|
return ar
|
|
|
|
|
|
|
|
def is_transluc(material):
|
|
|
|
nodes = material.node_tree.nodes
|
|
|
|
output_node = cycles.node_by_type(nodes, 'OUTPUT_MATERIAL')
|
|
|
|
if output_node == None or output_node.inputs[0].is_linked == False:
|
|
|
|
return False
|
|
|
|
|
|
|
|
surface_node = output_node.inputs[0].links[0].from_node
|
|
|
|
return is_transluc_traverse(surface_node)
|
|
|
|
|
|
|
|
def is_transluc_traverse(node):
|
2017-01-12 12:11:25 +01:00
|
|
|
# TODO: traverse groups
|
2016-12-19 01:25:22 +01:00
|
|
|
if is_transluc_type(node):
|
|
|
|
return True
|
|
|
|
for inp in node.inputs:
|
|
|
|
if inp.is_linked:
|
|
|
|
res = is_transluc_traverse(inp.links[0].from_node)
|
|
|
|
if res:
|
|
|
|
return True
|
|
|
|
return False
|
|
|
|
|
|
|
|
def is_transluc_type(node):
|
|
|
|
if node.type == 'BSDF_GLASS' or \
|
|
|
|
node.type == 'BSDF_TRANSPARENT' or \
|
|
|
|
node.type == 'BSDF_TRANSLUCENT' or \
|
|
|
|
(node.type == 'GROUP' and node.node_tree.name.startswith('Armory PBR') and (node.inputs[12].is_linked or node.inputs[12].default_value != 1.0)):
|
|
|
|
return True
|
|
|
|
return False
|