From f41739dc7aab64656726f40952a727c3adbd2849 Mon Sep 17 00:00:00 2001 From: Alexander Date: Mon, 18 May 2020 18:16:59 +0200 Subject: [PATCH] Begin atlas post-packing, fix bugs --- Addon/Keymap/keymap.py | 20 ++++---- Addon/Operators/lighttools.py | 2 +- Addon/Panels/scene.py | 86 +++++++++++++++++++---------------- Addon/Properties/scene.py | 12 ++++- Addon/Utility/objectconfig.py | 20 ++++---- Addon/Utility/utility.py | 30 ++++++++---- 6 files changed, 101 insertions(+), 69 deletions(-) diff --git a/Addon/Keymap/keymap.py b/Addon/Keymap/keymap.py index ce9b1e2..6fa86e4 100644 --- a/Addon/Keymap/keymap.py +++ b/Addon/Keymap/keymap.py @@ -6,14 +6,16 @@ tlm_keymaps = [] def register(): - winman = bpy.context.window_manager - keyman = winman.keyconfigs.addon.keymaps.new(name='Window', space_type='EMPTY', region_type="WINDOW") - keyman.keymap_items.new(build.TLM_BuildLightmaps.bl_idname, type='F6', value='PRESS') - keyman.keymap_items.new(clean.TLM_CleanLightmaps.bl_idname, type='F7', value='PRESS') - tlm_keymaps.append(keyman) + pass + # winman = bpy.context.window_manager + # keyman = winman.keyconfigs.addon.keymaps.new(name='Window', space_type='EMPTY', region_type="WINDOW") + # keyman.keymap_items.new(build.TLM_BuildLightmaps.bl_idname, type='F6', value='PRESS') + # keyman.keymap_items.new(clean.TLM_CleanLightmaps.bl_idname, type='F7', value='PRESS') + # tlm_keymaps.append(keyman) def unregister(): - winman = bpy.context.window_manager - for keyman in tlm_keymaps: - winman.keyconfigs.addon.keymaps.remove(keyman) - del tlm_keymaps[:] \ No newline at end of file + pass + # winman = bpy.context.window_manager + # for keyman in tlm_keymaps: + # winman.keyconfigs.addon.keymaps.remove(keyman) + # del tlm_keymaps[:] \ No newline at end of file diff --git a/Addon/Operators/lighttools.py b/Addon/Operators/lighttools.py index b94c998..621d8a5 100644 --- a/Addon/Operators/lighttools.py +++ b/Addon/Operators/lighttools.py @@ -1,4 +1,4 @@ -import bpy, math, os, cv2 +import bpy, math, os from bpy.app.handlers import persistent def Log2(x): diff --git a/Addon/Panels/scene.py b/Addon/Panels/scene.py index c7e4370..d79d6aa 100644 --- a/Addon/Panels/scene.py +++ b/Addon/Panels/scene.py @@ -348,43 +348,51 @@ def draw(self, context): sceneProperties = scene.TLM_SceneProperties layout.label(text="Atlas Groups") - rows = 2 - if len(scene.TLM_AtlasList) > 1: - rows = 4 row = layout.row() - row.template_list("TLM_UL_AtlasList", "The_List", scene, "TLM_AtlasList", scene, "TLM_AtlasList_index", rows=rows) - col = row.column(align=True) - col.operator("tlm_atlaslist.new_item", icon='ADD', text="") - col.operator("tlm_atlaslist.delete_item", icon='REMOVE', text="") - #col.menu("ARM_MT_BakeListSpecials", icon='DOWNARROW_HLT', text="") - - # if len(scene.TLM_AtlasList) > 1: - # col.separator() - # op = col.operator("arm_bakelist.move_item", icon='TRIA_UP', text="") - # op.direction = 'UP' - # op = col.operator("arm_bakelist.move_item", icon='TRIA_DOWN', text="") - # op.direction = 'DOWN' - - if scene.TLM_AtlasList_index >= 0 and len(scene.TLM_AtlasList) > 0: - item = scene.TLM_AtlasList[scene.TLM_AtlasList_index] - #layout.prop_search(item, "obj", bpy.data, "objects", text="Object") - #layout.prop(item, "res_x") - layout.prop(item, "tlm_atlas_lightmap_unwrap_mode") - layout.prop(item, "tlm_atlas_lightmap_resolution") - layout.prop(item, "tlm_atlas_unwrap_margin") - - amount = 0 - - for obj in bpy.data.objects: - if obj.TLM_ObjectProperties.tlm_mesh_lightmap_use: - if obj.TLM_ObjectProperties.tlm_mesh_lightmap_unwrap_mode == "AtlasGroup": - if obj.TLM_ObjectProperties.tlm_atlas_pointer == item.name: - amount = amount + 1 - - layout.label(text="Objects: " + str(amount)) - - # layout.use_property_split = True - # layout.use_property_decorate = False - # layout.label(text="Enable for selection") - # layout.label(text="Disable for selection") - # layout.label(text="Something...") \ No newline at end of file + row.prop(sceneProperties, "tlm_atlas_mode", expand=True) + + if sceneProperties.tlm_atlas_mode == "Prepack": + + rows = 2 + if len(scene.TLM_AtlasList) > 1: + rows = 4 + row = layout.row() + row.template_list("TLM_UL_AtlasList", "The_List", scene, "TLM_AtlasList", scene, "TLM_AtlasList_index", rows=rows) + col = row.column(align=True) + col.operator("tlm_atlaslist.new_item", icon='ADD', text="") + col.operator("tlm_atlaslist.delete_item", icon='REMOVE', text="") + #col.menu("ARM_MT_BakeListSpecials", icon='DOWNARROW_HLT', text="") + + # if len(scene.TLM_AtlasList) > 1: + # col.separator() + # op = col.operator("arm_bakelist.move_item", icon='TRIA_UP', text="") + # op.direction = 'UP' + # op = col.operator("arm_bakelist.move_item", icon='TRIA_DOWN', text="") + # op.direction = 'DOWN' + + if scene.TLM_AtlasList_index >= 0 and len(scene.TLM_AtlasList) > 0: + item = scene.TLM_AtlasList[scene.TLM_AtlasList_index] + #layout.prop_search(item, "obj", bpy.data, "objects", text="Object") + #layout.prop(item, "res_x") + layout.prop(item, "tlm_atlas_lightmap_unwrap_mode") + layout.prop(item, "tlm_atlas_lightmap_resolution") + layout.prop(item, "tlm_atlas_unwrap_margin") + + amount = 0 + + for obj in bpy.data.objects: + if obj.TLM_ObjectProperties.tlm_mesh_lightmap_use: + if obj.TLM_ObjectProperties.tlm_mesh_lightmap_unwrap_mode == "AtlasGroup": + if obj.TLM_ObjectProperties.tlm_atlas_pointer == item.name: + amount = amount + 1 + + layout.label(text="Objects: " + str(amount)) + + # layout.use_property_split = True + # layout.use_property_decorate = False + # layout.label(text="Enable for selection") + # layout.label(text="Disable for selection") + # layout.label(text="Something...") + + else: + layout.label(text="Postpacking not yet available.") \ No newline at end of file diff --git a/Addon/Properties/scene.py b/Addon/Properties/scene.py index 05d9f09..039d712 100644 --- a/Addon/Properties/scene.py +++ b/Addon/Properties/scene.py @@ -106,7 +106,8 @@ class TLM_SceneProperties(bpy.types.PropertyGroup): default='Clean and restore') tlm_quality : EnumProperty( - items = [('Preview', 'Preview', 'TODO'), + items = [('Preview', 'Preview Exterior', 'TODO'), + ('Preview2', 'Preview Interior', 'TODO'), ('Medium', 'Medium', 'TODO'), ('High', 'High', 'TODO'), ('Production', 'Production', 'TODO'), @@ -538,4 +539,11 @@ class TLM_SceneProperties(bpy.types.PropertyGroup): tlm_compile_statistics : BoolProperty( name="Compile statistics", description="Todo.", - default=False) \ No newline at end of file + default=False) + + tlm_atlas_mode : EnumProperty( + items = [('Prepack', 'Pre-packaging', 'Todo.'), + ('Postpack', 'Post-packaging', 'Todo.')], + name = "Atlas mode", + description="TODO", + default='Prepack') \ No newline at end of file diff --git a/Addon/Utility/objectconfig.py b/Addon/Utility/objectconfig.py index cdc28e9..175901d 100644 --- a/Addon/Utility/objectconfig.py +++ b/Addon/Utility/objectconfig.py @@ -5,15 +5,19 @@ def configure_world(): pass def configure_lights(): - for obj in bpy.data.objects: - if obj.type == "LIGHT": - if obj.TLM_ObjectProperties.tlm_light_lightmap_use: - if obj.TLM_ObjectProperties.tlm_light_casts_shadows: - bpy.data.lights[obj.name].cycles.cast_shadow = True - else: - bpy.data.lights[obj.name].cycles.cast_shadow = False + pass + #Changed way lights are adjusted. Baked hidden with python property instead. + + + # for obj in bpy.data.objects: + # if obj.type == "LIGHT": + # if obj.TLM_ObjectProperties.tlm_light_lightmap_use: + # if obj.TLM_ObjectProperties.tlm_light_casts_shadows: + # bpy.data.lights[obj.name].cycles.cast_shadow = True + # else: + # bpy.data.lights[obj.name].cycles.cast_shadow = False - bpy.data.lights[obj.name].energy = bpy.data.lights[obj.name].energy * obj.TLM_ObjectProperties.tlm_light_intensity_scale + # bpy.data.lights[obj.name].energy = bpy.data.lights[obj.name].energy * obj.TLM_ObjectProperties.tlm_light_intensity_scale def configure_objects(self, scene): diff --git a/Addon/Utility/utility.py b/Addon/Utility/utility.py index a3372e1..29591d5 100644 --- a/Addon/Utility/utility.py +++ b/Addon/Utility/utility.py @@ -105,8 +105,8 @@ def set_settings(cycles, scene): cycles.volume_bounces = 1 cycles.caustics_reflective = False cycles.caustics_refractive = False - elif scene.TLM_SceneProperties.tlm_quality == "Medium": - cycles.samples = 256 + elif scene.TLM_SceneProperties.tlm_quality == "Preview2": + cycles.samples = 64 cycles.max_bounces = 2 cycles.diffuse_bounces = 2 cycles.glossy_bounces = 2 @@ -115,17 +115,17 @@ def set_settings(cycles, scene): cycles.volume_bounces = 2 cycles.caustics_reflective = False cycles.caustics_refractive = False - elif scene.TLM_SceneProperties.tlm_quality == "High": + elif scene.TLM_SceneProperties.tlm_quality == "Medium": cycles.samples = 512 - cycles.max_bounces = 128 - cycles.diffuse_bounces = 128 - cycles.glossy_bounces = 128 - cycles.transparent_max_bounces = 128 - cycles.transmission_bounces = 128 - cycles.volume_bounces = 128 + cycles.max_bounces = 2 + cycles.diffuse_bounces = 2 + cycles.glossy_bounces = 2 + cycles.transparent_max_bounces = 2 + cycles.transmission_bounces = 2 + cycles.volume_bounces = 2 cycles.caustics_reflective = False cycles.caustics_refractive = False - elif scene.TLM_SceneProperties.tlm_quality == "Production": + elif scene.TLM_SceneProperties.tlm_quality == "High": cycles.samples = 1024 cycles.max_bounces = 256 cycles.diffuse_bounces = 256 @@ -133,6 +133,16 @@ def set_settings(cycles, scene): cycles.transparent_max_bounces = 256 cycles.transmission_bounces = 256 cycles.volume_bounces = 256 + cycles.caustics_reflective = False + cycles.caustics_refractive = False + elif scene.TLM_SceneProperties.tlm_quality == "Production": + cycles.samples = 2048 + cycles.max_bounces = 512 + cycles.diffuse_bounces = 512 + cycles.glossy_bounces = 512 + cycles.transparent_max_bounces = 512 + cycles.transmission_bounces = 512 + cycles.volume_bounces = 512 cycles.caustics_reflective = True cycles.caustics_refractive = True else: #Custom