diff --git a/addons/vpx_lightmapper/vlm_export.py b/addons/vpx_lightmapper/vlm_export.py index 84ee964..88baf42 100644 --- a/addons/vpx_lightmapper/vlm_export.py +++ b/addons/vpx_lightmapper/vlm_export.py @@ -368,7 +368,8 @@ def append_structure(src_path, mode, hashed): col = vlm_collections.get_collection(bake_col, obj.vlmSettings.bake_collections, create=False) obj.data.validate() - obj.data.calc_normals_split() # compute loop normal (would be 0,0,0 otherwise) + if bpy.app.version < (4, 1, 0): # FIXME Remove for Blender 4.1 + obj.data.calc_normals_split() # compute loop normal (would be 0,0,0 otherwise) uv_layer_nested = obj.data.uv_layers.get("UVMap Nested") if not uv_layer_nested: logger.info(f'. Missing nested uv map for {obj.name}') diff --git a/addons/vpx_lightmapper/vlm_meshes_baker.py b/addons/vpx_lightmapper/vlm_meshes_baker.py index cd42a65..a6ca313 100644 --- a/addons/vpx_lightmapper/vlm_meshes_baker.py +++ b/addons/vpx_lightmapper/vlm_meshes_baker.py @@ -215,8 +215,8 @@ def create_bake_meshes(op, context): logger.info(f'. ERROR {obj_name} has an invalid modifier which was not applied') dup.modifiers.clear() - # Remove custom normals since they will be lost during mesh optimization - if optimize_mesh: + # FIXME Remove for Blender 4.1 + if bpy.app.version < (4, 1, 0) and optimize_mesh: # Remove custom normals since they will be lost during mesh optimization dup.data.free_normals_split() dup.data.use_auto_smooth = False # Don't use custom normals since we removed them with context.temp_override(active_object=dup, selected_objects=[dup]): @@ -225,7 +225,8 @@ def create_bake_meshes(op, context): # Save normals dup.data.validate() - dup.data.calc_normals_split() # compute loop normal (would 0,0,0 otherwise since we free them above) + if bpy.app.version < (4, 1, 0): # FIXME Remove for Blender 4.1 + dup.data.calc_normals_split() # compute loop normal (would 0,0,0 otherwise since we free them above) # Switch material to baked ones (needs to be done after applying modifiers which may create material slots) for poly in dup.data.polygons: @@ -461,7 +462,8 @@ def create_bake_meshes(op, context): prev_nestmap = bpy.data.objects[obj_name].vlmSettings.bake_nestmap if bpy.data.objects.get(obj_name) else -1 bake_instance = bpy.data.objects.new(obj_name, bake_mesh.copy()) # Remove face shading (lightmap are not made to be shaded and the pruning process breaks the shading) - bake_instance.data.free_normals_split() + if bpy.app.version < (4, 1, 0): # FIXME Remove for Blender 4.1 + bake_instance.data.free_normals_split() bake_instance.data.use_auto_smooth = False # Don't use custom normals since we removed them with context.temp_override(active_object=bake_instance, selected_objects=[bake_instance]): bpy.ops.object.shade_flat() diff --git a/addons/vpx_lightmapper/vlm_nestmap_baker.py b/addons/vpx_lightmapper/vlm_nestmap_baker.py index f2f5691..27a120d 100644 --- a/addons/vpx_lightmapper/vlm_nestmap_baker.py +++ b/addons/vpx_lightmapper/vlm_nestmap_baker.py @@ -55,6 +55,8 @@ def render_nestmaps(op, context): 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 # 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 not obj.vlmSettings.is_lightmap or obj.vlmSettings.bake_hdr_range <= 1.0: + if obj.vlmSettings.bake_hdr_range > 1.0: + logger.error('ERROR: Object {obj.name} is packed to an LDR nestmap while it has an HDR range of {obj.vlmSettings.bake_hdr_range}. Render will be wrongly clamped. You need to reduce bake lighting strength to avoid this.') if has_normalmap: to_nest_ldr_nm.append(obj) else: