Skip to content

Commit

Permalink
Always nest all bakemap as LDR (HDR for lightmap only)
Browse files Browse the repository at this point in the history
  • Loading branch information
vbousquet committed Aug 20, 2023
1 parent 8046205 commit 4c0a0a8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 5 additions & 3 deletions addons/vpx_lightmapper/vlm_meshes_baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,14 @@ def create_bake_meshes(op, context):
to_bake.append((obj_name, bake_col, [obj_name], obj_name, not bake_col.vlmSettings.is_opaque))
else:
sync_obj = None
sync_transform = None
for obj_name in object_names:
obj = bpy.data.objects[obj_name]
if obj.vlmSettings.is_movable:
if sync_obj != None:
logger.info(f'. ERROR: Bake collection {bake_col.name} bakes to a group but more than one object is marked as movable.')
if sync_obj and sync_transform != obj.matrix_world:
logger.info(f'. ERROR: Bake collection {bake_col.name} bakes to a group multiple objects are marked as movable with different transforms. Only check the one you want to define the origin of the group.')
sync_obj = obj_name
sync_transform = obj.matrix_world
to_bake.append((bake_col.name, bake_col, object_names, sync_obj, not bake_col.vlmSettings.is_opaque))

# Create all solid bake meshes
Expand Down Expand Up @@ -497,7 +499,7 @@ def create_bake_meshes(op, context):
result_col.objects.unlink(bake_instance)
#logger.info(f". Mesh {bake_name} has no more faces after optimization for {light_name} lighting")
else:
logger.info(f'. {len(bake_instance.data.polygons):>6} faces out of {n_faces:>6} kept (HDR range: {hdr_range:>5.2f}) for {bake_col if sync_obj is None else bake_name}')
logger.info(f'. {len(bake_instance.data.polygons):>6} faces out of {n_faces:>6} kept (HDR range: {hdr_range:>5.2f}) for {obj_name}')
if sync_obj and bpy.data.objects[sync_obj]:
bake_instance.matrix_world = bpy.data.objects[sync_obj].matrix_world
bake_instance.vlmSettings.bake_type = 'lightmap'
Expand Down
5 changes: 3 additions & 2 deletions addons/vpx_lightmapper/vlm_nestmap_baker.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@ def render_nestmaps(op, context):
obj.data.uv_layers.new(name='UVMap Nested')
obj.data.uv_layers.active = uvmap
has_normalmap = next((mat for mat in obj.data.materials if mat.get('VLM.HasNormalMap') == True and mat['VLM.IsLightmap'] == False), None) is not None
if obj.vlmSettings.bake_type == 'active' or obj.vlmSettings.bake_hdr_range <= 1.0:
# VPX only supports opaque HDR therefore we pack all non lightmaps as LDR (luckily base bake is usually LDR, and we don't really need this for lightmaps which are RGB only)
if obj.vlmSettings.bake_type != 'lightmap' or obj.vlmSettings.bake_hdr_range <= 1.0:
if has_normalmap:
to_nest_ldr_nm.append(obj)
else:
to_nest_ldr.append(obj)
else: # VPX only supports opaque HDR (luckily we don't really need this since lightmaps are RGB only)
else:
if has_normalmap:
to_nest_hdr_nm.append(obj)
else:
Expand Down

0 comments on commit 4c0a0a8

Please sign in to comment.