Skip to content

Commit

Permalink
feat: support no 'non-color' setup
Browse files Browse the repository at this point in the history
  • Loading branch information
saturday06 committed Oct 14, 2023
1 parent 568f160 commit 9e84816
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
24 changes: 23 additions & 1 deletion io_scene_vrm/importer/gltf2_addon_vrm_importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,29 @@ def assign_texture(
if isinstance(source, int):
image = self.images.get(source)
if image:
image.colorspace_settings.name = texture.colorspace
# https://github.com/saturday06/VRM-Addon-for-Blender/issues/336#issuecomment-1760729404
colorspace_settings = image.colorspace_settings
name_property = colorspace_settings.bl_rna.properties["name"]
if isinstance(name_property, bpy.types.EnumProperty):
identifiers = [
enum_item.identifier for enum_item in name_property.enum_items
]
non_color = "Non-Color"
generic_data = "Generic Data"
if texture.colorspace in identifiers:
colorspace_settings.name = texture.colorspace
elif (
texture.colorspace == non_color and generic_data in identifiers
):
colorspace_settings.name = generic_data
else:
logger.error(
f"image.colorspace_settings.name doesn't support {texture.colorspace}."
+ f" Supported colorspaces are {identifiers}"
)
else:
logger.error("image.colorspace_settings.name is not a EnumProperty")

texture.source = image

sampler = texture_dict.get("sampler")
Expand Down

0 comments on commit 9e84816

Please sign in to comment.