Skip to content

Commit

Permalink
hotfixed for dev0
Browse files Browse the repository at this point in the history
- don't try to set color mode for missing textures
- bunch of fixes for Autosetter
  • Loading branch information
HenryOfCarim committed Aug 24, 2024
1 parent 2a0c48f commit e611220
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
20 changes: 17 additions & 3 deletions albam/blender_ui/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,20 +344,32 @@ def set_image_albam_attr(blender_material, app_id, local_path):
"re1": (24, 20, 19, 31),
"rev1": (23, 19, 25, 31),
"rev2": (24, 20, 25, 31),
"re6": (24, 20, 25, 31),
}

UNKNOWN_TYPE = {
"re0": "0x209d",
"re1": "0x209d",
"rev1": "0xa09d",
"rev2": "0x209d",
"re6": "0x9a",
}

if not blender_material or not blender_material.node_tree:
return

for tn in blender_material.node_tree.nodes:
if not tn.type == "TEX_IMAGE":
continue
type = blender_texture_to_texture_code(tn)
name = ntpath.splitext(tn.image.name)[0]
if tn.image:
name = ntpath.splitext(tn.image.name)[0]
else:
continue
if not tn.image.albam_asset.relative_path:
tn.image.albam_asset.relative_path = local_path + name + '.tex'
tn.image.albam_asset.app_id = app_id
tex_157_props = tn.image.albam_custom_properties.get_custom_properties_for_appid(app_id)
if app_id in ["re0", "re1", "rev1", "rev2"]:
if app_id in TEX_COMPRESSION:
tex_compr_preset = TEX_COMPRESSION.get(app_id)
if type == 0:
tex_157_props.compression_format = tex_compr_preset[1]
Expand All @@ -367,6 +379,8 @@ def set_image_albam_attr(blender_material, app_id, local_path):
tex_157_props.compression_format = tex_compr_preset[2]
if type == 7:
tex_157_props.compression_format = tex_compr_preset[3]
if app_id in UNKNOWN_TYPE:
tex_157_props.unk_type = UNKNOWN_TYPE.get(app_id)


def rename_bones(armature_ob, names_preset):
Expand Down
4 changes: 2 additions & 2 deletions albam/engines/mtfw/texture.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def assign_textures(mtfw_material, bl_material, textures, mrl):
if texture_target is not None:
texture_node.image = texture_target
texture_code_to_blender_texture(tex_type_blender.value, texture_node, bl_material)
if tex_index and tex_type_blender.value in NON_SRGB_IMAGE_TYPE:
if texture_node.image and tex_type_blender.value in NON_SRGB_IMAGE_TYPE:
texture_node.image.colorspace_settings.name = "Non-Color"
except IndexError:
print(f"tex_index {tex_index} not found. Texture len(): {len(textures)}")
Expand All @@ -343,7 +343,7 @@ def old_assignment(mtfw_material, bl_material, textures, from_mrl=False):
texture_node.image = texture_target
texture_code_to_blender_texture(texture_type.value, texture_node, bl_material)
# change color settings for normal and detail maps
if texture_type.value in NON_SRGB_IMAGE_TYPE:
if texture_node.image and texture_type.value in NON_SRGB_IMAGE_TYPE:
texture_node.image.colorspace_settings.name = "Non-Color"


Expand Down

0 comments on commit e611220

Please sign in to comment.