def parse_defs(node_group): rn = nodes.get_node_by_type(node_group, 'COMPOSITE') if rn == None: return '' parse_defs.defs = [] build_node(node_group, nodes.get_input_node(node_group, rn, 0)) # To string s = '' for d in parse_defs.defs: s += d return s
def build_node_tree(world): output = {} dat = {} output['material_datas'] = [dat] wname = arm.utils.safestr(world.name) dat['name'] = wname + '_material' context = {} dat['contexts'] = [context] context['name'] = 'world' context['bind_constants'] = [] context['bind_textures'] = [] bpy.data.worlds['Arm'].world_defs = '' # Traverse world node tree output_node = nodes.get_node_by_type(world.node_tree, 'OUTPUT_WORLD') if output_node != None: parse_world_output(world, output_node, context) # Clear to color if no texture or sky is provided wrd = bpy.data.worlds['Arm'] if '_EnvSky' not in wrd.world_defs and '_EnvTex' not in wrd.world_defs: if '_EnvImg' not in wrd.world_defs: wrd.world_defs += '_EnvCol' # Irradiance json file name world.world_envtex_name = wname world.world_envtex_irr_name = wname write_probes.write_color_irradiance(wname, world.world_envtex_color) # Clouds enabled if wrd.generate_clouds: wrd.world_defs += '_EnvClouds' # Percentage closer soft shadows if wrd.generate_pcss_state == 'On': wrd.world_defs += '_PCSS' sdk_path = arm.utils.get_sdk_path() assets.add(sdk_path + 'armory/Assets/noise64.png') assets.add_embedded_data('noise64.png') # Screen-space ray-traced shadows if wrd.generate_ssrs: wrd.world_defs += '_SSRS' if wrd.generate_two_sided_area_lamp: wrd.world_defs += '_TwoSidedAreaLamp' # Alternative models if wrd.lighting_model == 'Cycles': wrd.world_defs += '_Cycles' # TODO: Lamp texture test.. if wrd.generate_lamp_texture != '': bpy.data.worlds['Arm'].world_defs += '_LampColTex' if not wrd.generate_lamp_falloff: bpy.data.worlds['Arm'].world_defs += '_NoLampFalloff' voxelgi = False for cam in bpy.data.cameras: if cam.is_probe: wrd.world_defs += '_Probes' if cam.rp_shadowmap == 'None': wrd.world_defs += '_NoShadows' assets.add_khafile_def('arm_no_shadows') if cam.rp_voxelgi: voxelgi = True if cam.rp_dfrs: wrd.world_defs += '_DFRS' assets.add_khafile_def('arm_sdf') if cam.rp_dfao: wrd.world_defs += '_DFAO' assets.add_khafile_def('arm_sdf') if voxelgi: assets.add_khafile_def('arm_voxelgi') if wrd.voxelgi_revoxelize: assets.add_khafile_def('arm_voxelgi_revox') if wrd.voxelgi_multibounce: wrd.world_defs += '_VoxelGIMulti' wrd.world_defs += '_VoxelGI' wrd.world_defs += '_Rad' # Always do radiance for voxels wrd.world_defs += '_Irr' if arm.utils.get_gapi().startswith( 'direct3d'): # Flip Y axis in drawQuad command wrd.world_defs += '_InvY' # Area lamps for lamp in bpy.data.lamps: if lamp.type == 'AREA': wrd.world_defs += '_PolyLight' break # Data will be written after render path has been processed to gather all defines return output
def build_node_tree(world): output = {} dat = {} output['material_datas'] = [dat] wname = arm.utils.safestr(world.name) dat['name'] = wname + '_material' context = {} dat['contexts'] = [context] context['name'] = 'world' context['bind_constants'] = [] context['bind_textures'] = [] wrd = bpy.data.worlds['Arm'] wrd.world_defs = '' rpdat = arm.utils.get_rp() # Traverse world node tree parsed = False if world.node_tree != None: output_node = nodes.get_node_by_type(world.node_tree, 'OUTPUT_WORLD') if output_node != None: parse_world_output(world, output_node, context) parsed = True if parsed == False: if wrd.arm_irradiance and rpdat.arm_material_model != 'Restricted': wrd.world_defs += '_Irr' envmap_strength_const = {} envmap_strength_const['name'] = 'envmapStrength' envmap_strength_const['float'] = 1.0 context['bind_constants'].append(envmap_strength_const) world.arm_envtex_color = [0.051, 0.051, 0.051, 1.0] world.arm_envtex_strength = envmap_strength_const['float'] # Clear to color if no texture or sky is provided if '_EnvSky' not in wrd.world_defs and '_EnvTex' not in wrd.world_defs: if '_EnvImg' not in wrd.world_defs: wrd.world_defs += '_EnvCol' # Irradiance json file name world.arm_envtex_name = wname world.arm_envtex_irr_name = wname write_probes.write_color_irradiance(wname, world.arm_envtex_color) # Clouds enabled if rpdat.arm_clouds: wrd.world_defs += '_EnvClouds' # Percentage closer soft shadows if rpdat.arm_pcss_state == 'On': wrd.world_defs += '_PCSS' sdk_path = arm.utils.get_sdk_path() assets.add(sdk_path + 'armory/Assets/noise64.png') assets.add_embedded_data('noise64.png') # Screen-space ray-traced shadows if rpdat.arm_ssrs: wrd.world_defs += '_SSRS' if wrd.arm_two_sided_area_lamp: wrd.world_defs += '_TwoSidedAreaLamp' # Store contexts if rpdat.rp_hdr == False: wrd.world_defs += '_LDR' # Alternative models if rpdat.arm_material_model == 'Cycles': wrd.world_defs += '_Cycles' # TODO: Lamp texture test.. if wrd.arm_lamp_texture != '': wrd.world_defs += '_LampColTex' if wrd.arm_lamp_ies_texture != '': wrd.world_defs += '_LampIES' assets.add_embedded_data('iestexture.png') voxelgi = False voxelao = False if rpdat.rp_shadowmap == 'None': wrd.world_defs += '_NoShadows' assets.add_khafile_def('arm_no_shadows') if rpdat.rp_voxelgi: voxelgi = True elif rpdat.rp_voxelao: voxelao = True if rpdat.rp_dfrs: wrd.world_defs += '_DFRS' assets.add_khafile_def('arm_sdf') if rpdat.rp_dfao: wrd.world_defs += '_DFAO' assets.add_khafile_def('arm_sdf') if rpdat.rp_dfgi: wrd.world_defs += '_DFGI' assets.add_khafile_def('arm_sdf') wrd.world_defs += '_Rad' # Always do radiance for gi wrd.world_defs += '_Irr' if voxelgi: assets.add_khafile_def('arm_voxelgi') if rpdat.arm_voxelgi_revoxelize: assets.add_khafile_def('arm_voxelgi_revox') if rpdat.arm_voxelgi_camera: wrd.world_defs += '_VoxelGICam' if rpdat.arm_voxelgi_shadows: wrd.world_defs += '_VoxelGIDirect' wrd.world_defs += '_VoxelGIShadow' if rpdat.arm_voxelgi_refraction: wrd.world_defs += '_VoxelGIDirect' wrd.world_defs += '_VoxelGIRefract' wrd.world_defs += '_VoxelGI' wrd.world_defs += '_Rad' # Always do radiance for voxels wrd.world_defs += '_Irr' elif voxelao: assets.add_khafile_def('arm_voxelgi') if rpdat.arm_voxelgi_revoxelize: assets.add_khafile_def('arm_voxelgi_revox') wrd.world_defs += '_VoxelAO' wrd.world_defs += '_Rad' wrd.world_defs += '_Irr' if arm.utils.get_gapi().startswith( 'direct3d'): # Flip Y axis in drawQuad command wrd.world_defs += '_InvY' # Area lamps for lamp in bpy.data.lamps: if lamp.type == 'AREA': wrd.world_defs += '_PolyLight' break # Data will be written after render path has been processed to gather all defines return output