Skip to content

Commit

Permalink
Begin atlas post-packing, fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Naxela committed May 18, 2020
1 parent 39e1591 commit f41739d
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 69 deletions.
20 changes: 11 additions & 9 deletions Addon/Keymap/keymap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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[:]
pass
# winman = bpy.context.window_manager
# for keyman in tlm_keymaps:
# winman.keyconfigs.addon.keymaps.remove(keyman)
# del tlm_keymaps[:]
2 changes: 1 addition & 1 deletion Addon/Operators/lighttools.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import bpy, math, os, cv2
import bpy, math, os
from bpy.app.handlers import persistent

def Log2(x):
Expand Down
86 changes: 47 additions & 39 deletions Addon/Panels/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...")
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.")
12 changes: 10 additions & 2 deletions Addon/Properties/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -538,4 +539,11 @@ class TLM_SceneProperties(bpy.types.PropertyGroup):
tlm_compile_statistics : BoolProperty(
name="Compile statistics",
description="Todo.",
default=False)
default=False)

tlm_atlas_mode : EnumProperty(
items = [('Prepack', 'Pre-packaging', 'Todo.'),
('Postpack', 'Post-packaging', 'Todo.')],
name = "Atlas mode",
description="TODO",
default='Prepack')
20 changes: 12 additions & 8 deletions Addon/Utility/objectconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down
30 changes: 20 additions & 10 deletions Addon/Utility/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -115,24 +115,34 @@ 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
cycles.glossy_bounces = 256
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
Expand Down

0 comments on commit f41739d

Please sign in to comment.