Improve low render path

This commit is contained in:
Lubos Lenco 2017-09-06 13:28:59 +02:00
parent f46c44e3ee
commit 51a158fad0
4 changed files with 97 additions and 67 deletions

View file

@ -3016,9 +3016,9 @@ class ArmoryExporter:
o['traits'].append(constr_trait)
def post_export_world(self, world, o):
defs = bpy.data.worlds['Arm'].world_defs
wrd = bpy.data.worlds['Arm']
bgcol = world.arm_envtex_color
if '_LDR' in defs: # No compositor used
if '_LDR' in wrd.world_defs: # No compositor used
for i in range(0, 3):
bgcol[i] = pow(bgcol[i], 1.0 / 2.2)
o['background_color'] = arm.utils.color_to_int(bgcol)
@ -3026,30 +3026,46 @@ class ArmoryExporter:
wmat_name = arm.utils.safestr(world.name) + '_material'
o['material_ref'] = wmat_name + '/' + wmat_name + '/world'
o['probes'] = []
# Main probe
world_arm_radiance = False
arm_irradiance = True #'_EnvTex' in defs or '_EnvSky' in defs or '_EnvCon' in defs
restricted = wrd.arm_rplist[wrd.arm_rplist_index].arm_material_model == 'Restricted'
arm_irradiance = wrd.arm_irradiance and not restricted
arm_radiance = False
disable_hdr = world.arm_envtex_name.endswith('.jpg')
radtex = world.arm_envtex_name.rsplit('.', 1)[0]
irrsharmonics = world.arm_envtex_irr_name
# Radiance
if '_EnvTex' in defs:
world_arm_radiance = bpy.data.worlds['Arm'].arm_radiance
elif '_EnvSky' in defs and bpy.data.worlds['Arm'].arm_radiance_sky:
world_arm_radiance = bpy.data.worlds['Arm'].arm_radiance
if '_EnvTex' in wrd.world_defs:
arm_radiance = bpy.data.worlds['Arm'].arm_radiance
elif '_EnvSky' in wrd.world_defs and bpy.data.worlds['Arm'].arm_radiance_sky:
arm_radiance = bpy.data.worlds['Arm'].arm_radiance
radtex = 'hosek'
num_mips = world.arm_envtex_num_mips
strength = world.arm_envtex_strength
po = self.make_probe(world.name, irrsharmonics, radtex, num_mips, strength, 1.0, [0, 0, 0], [0, 0, 0], world_arm_radiance, arm_irradiance, disable_hdr)
o['probes'].append(po)
if '_EnvSky' in defs:
po = {}
po['name'] = world.name
if arm_irradiance:
po['irradiance'] = irrsharmonics + '_irradiance'
if arm_radiance:
po['radiance'] = radtex + '_radiance'
if disable_hdr:
po['radiance'] += '.jpg'
else:
po['radiance'] += '.hdr'
po['radiance_mipmaps'] = num_mips
else:
po['irradiance'] = '' # No irradiance data, fallback to default at runtime
po['strength'] = strength
po['blending'] = 1.0
po['volume'] = [0, 0, 0]
po['volume_center'] = [0, 0, 0]
if '_EnvSky' in wrd.world_defs:
# Sky data for probe
po['sun_direction'] = list(world.arm_envtex_sun_direction)
po['turbidity'] = world.arm_envtex_turbidity
po['ground_albedo'] = world.arm_envtex_ground_albedo
o['probes'].append(po)
def post_export_grease_pencil(self, gp):
o = {}
@ -3153,23 +3169,3 @@ class ArmoryExporter:
co['fill_color'] = [color.fill_color[0], color.fill_color[1], color.fill_color[2]]
co['fill_alpha'] = color.fill_alpha
return co
def make_probe(self, id, irrsharmonics, radtex, mipmaps, strength, blending, volume, volume_center, arm_radiance, arm_irradiance, disable_hdr):
po = {}
po['name'] = id
if arm_radiance:
po['radiance'] = radtex + '_radiance'
if disable_hdr:
po['radiance'] += '.jpg'
else:
po['radiance'] += '.hdr'
po['radiance_mipmaps'] = mipmaps
if arm_irradiance:
po['irradiance'] = irrsharmonics + '_irradiance'
else:
po['irradiance'] = '' # No irradiance data, fallback to default at runtime
po['strength'] = strength
po['blending'] = blending
po['volume'] = volume
po['volume_center'] = volume_center
return po

View file

@ -226,7 +226,7 @@ def set_preset(self, context, preset):
rpdat.rp_decals_state = 'Off'
rpdat.rp_sss_state = 'Off'
rpdat.rp_hdr = False
rpdat.rp_background = 'World'
rpdat.rp_background = 'Clear'
rpdat.rp_stereo = False
rpdat.rp_greasepencil = False
rpdat.rp_voxelgi = False

View file

@ -49,7 +49,7 @@ def build_node_tree(world):
parse_world_output(world, output_node, context)
parsed = True
if parsed == False:
if wrd.arm_irradiance:
if wrd.arm_irradiance and wrd.arm_rplist[wrd.arm_rplist_index].arm_material_model != 'Restricted':
wrd.world_defs += '_Irr'
envmap_strength_const = {}
envmap_strength_const['name'] = 'envmapStrength'
@ -185,13 +185,14 @@ def parse_world_output(world, node, context):
def parse_surface(world, node, context):
wrd = bpy.data.worlds['Arm']
restricted = wrd.arm_rplist[wrd.arm_rplist_index].arm_material_model == 'Restricted'
# Extract environment strength
if node.type == 'BACKGROUND':
# Append irradiance define
if wrd.arm_irradiance:
bpy.data.worlds['Arm'].world_defs += '_Irr'
if wrd.arm_irradiance and not restricted:
wrd.world_defs += '_Irr'
# Strength
envmap_strength_const = {}
@ -210,6 +211,7 @@ def parse_surface(world, node, context):
def parse_color(world, node, context, envmap_strength_const):
wrd = bpy.data.worlds['Arm']
restricted = wrd.arm_rplist[wrd.arm_rplist_index].arm_material_model == 'Restricted'
# Env map included
if node.type == 'TEX_ENVIRONMENT' and node.image != None:
@ -285,17 +287,17 @@ def parse_color(world, node, context, envmap_strength_const):
world.arm_envtex_num_mips = mip_count
# Append envtex define
bpy.data.worlds['Arm'].world_defs += '_EnvTex'
wrd.world_defs += '_EnvTex'
# Append LDR define
if disable_hdr:
bpy.data.worlds['Arm'].world_defs += '_EnvLDR'
wrd.world_defs += '_EnvLDR'
# Append radiance define
if wrd.arm_irradiance and wrd.arm_radiance:
bpy.data.worlds['Arm'].world_defs += '_Rad'
if wrd.arm_irradiance and wrd.arm_radiance and not restricted:
wrd.world_defs += '_Rad'
# Static image background
elif node.type == 'TEX_IMAGE':
bpy.data.worlds['Arm'].world_defs += '_EnvImg'
wrd.world_defs += '_EnvImg'
tex = {}
context['bind_textures'].append(tex)
tex['name'] = 'envmap'
@ -330,7 +332,7 @@ def parse_color(world, node, context, envmap_strength_const):
# Match to cycles
envmap_strength_const['float'] *= 0.1
bpy.data.worlds['Arm'].world_defs += '_EnvSky'
wrd.world_defs += '_EnvSky'
# Append sky properties to material
const = {}
const['name'] = 'sunDirection'
@ -349,8 +351,8 @@ def parse_color(world, node, context, envmap_strength_const):
write_probes.write_sky_irradiance(wname)
# Radiance
if wrd.arm_radiance_sky and wrd.arm_radiance and wrd.arm_irradiance:
bpy.data.worlds['Arm'].world_defs += '_Rad'
if wrd.arm_radiance_sky and wrd.arm_radiance and wrd.arm_irradiance and not restricted:
wrd.world_defs += '_Rad'
if wrd.arm_radiance_sky_type == 'Hosek':
hosek_path = 'armory/Assets/hosek/'

View file

@ -138,23 +138,20 @@ class ArmTraitListDeleteItem(bpy.types.Operator):
@classmethod
def poll(self, context):
""" Enable if there's something in the list """
if self.is_object:
obj = bpy.context.object
else:
obj = bpy.context.scene
obj = bpy.context.object
if obj == None:
return False
return len(obj.arm_traitlist) > 0
def execute(self, context):
if self.is_object:
obj = bpy.context.object
else:
obj = bpy.context.scene
list = obj.arm_traitlist
obj = bpy.context.object
lst = obj.arm_traitlist
index = obj.arm_traitlist_index
list.remove(index)
if len(lst) <= index:
return{'FINISHED'}
lst.remove(index)
if index > 0:
index = index - 1
@ -162,6 +159,36 @@ class ArmTraitListDeleteItem(bpy.types.Operator):
obj.arm_traitlist_index = index
return{'FINISHED'}
class ArmTraitListDeleteItemScene(bpy.types.Operator):
# Delete the selected item from the list
bl_idname = "arm_traitlist.delete_item_scene"
bl_label = "Deletes an item"
is_object = bpy.props.BoolProperty(name="", description="A name for this item", default=False)
@classmethod
def poll(self, context):
""" Enable if there's something in the list """
obj = bpy.context.scene
if obj == None:
return False
return len(obj.arm_traitlist) > 0
def execute(self, context):
obj = bpy.context.scene
lst = obj.arm_traitlist
index = obj.arm_traitlist_index
if len(lst) <= index:
return{'FINISHED'}
lst.remove(index)
if index > 0:
index = index - 1
obj.arm_traitlist_index = index
return{'FINISHED'}
class ArmTraitListMoveItem(bpy.types.Operator):
# Move an item in the list
@ -174,16 +201,16 @@ class ArmTraitListMoveItem(bpy.types.Operator):
is_object = bpy.props.BoolProperty(name="", description="A name for this item", default=False)
@classmethod
def poll(self, context):
if self.is_object:
obj = bpy.context.object
else:
obj = bpy.context.scene
if obj == None:
return False
""" Enable if there's something in the list. """
return len(obj.arm_traitlist) > 0
# @classmethod
# def poll(self, context):
# if self.is_object:
# obj = bpy.context.object
# else:
# obj = bpy.context.scene
# if obj == None:
# return False
# """ Enable if there's something in the list. """
# return len(obj.arm_traitlist) > 0
def move_index(self):
@ -423,7 +450,10 @@ def draw_traits(layout, obj, is_object):
col = row.column(align=True)
op = col.operator("arm_traitlist.new_item", icon='ZOOMIN', text="")
op.is_object = is_object
op = col.operator("arm_traitlist.delete_item", icon='ZOOMOUT', text="")#.all = False
if is_object:
op = col.operator("arm_traitlist.delete_item", icon='ZOOMOUT', text="")#.all = False
else:
op = col.operator("arm_traitlist.delete_item_scene", icon='ZOOMOUT', text="")#.all = False
op.is_object = is_object
if len(obj.arm_traitlist) > 1:
@ -540,6 +570,7 @@ def register():
bpy.utils.register_class(ArmTraitList)
bpy.utils.register_class(ArmTraitListNewItem)
bpy.utils.register_class(ArmTraitListDeleteItem)
bpy.utils.register_class(ArmTraitListDeleteItemScene)
bpy.utils.register_class(ArmTraitListMoveItem)
bpy.utils.register_class(ArmEditScriptButton)
bpy.utils.register_class(ArmEditBundledScriptButton)
@ -560,6 +591,7 @@ def unregister():
bpy.utils.unregister_class(ArmTraitList)
bpy.utils.unregister_class(ArmTraitListNewItem)
bpy.utils.unregister_class(ArmTraitListDeleteItem)
bpy.utils.unregister_class(ArmTraitListDeleteItemScene)
bpy.utils.unregister_class(ArmTraitListMoveItem)
bpy.utils.unregister_class(ArmEditScriptButton)
bpy.utils.unregister_class(ArmEditBundledScriptButton)