restore some of the codes on lib and collect images

This commit is contained in:
Kayla Man 2024-01-15 19:17:12 +08:00
parent 00ab2bc9f6
commit 1ac89d2efa
2 changed files with 3 additions and 35 deletions

View file

@ -643,33 +643,3 @@ def prompt_new_file_with_mesh(mesh_filepath):
return
return project_mesh
def has_rgb_channel_in_texture_set(texture_set_name, map_identifier):
"""Function to check whether the texture has RGB channel.
Args:
texture_set_name (str): Name of Texture Set
map_identifier (str): Map identifier
Returns:
bool: Whether the channel type identifier has RGB channel or not
in the texture stack.
"""
# 2D_View is always True as it exports all texture maps
texture_stack = (
substance_painter.textureset.Stack.from_name(texture_set_name)
)
# 2D_View is always True as it exports all texture maps
if map_identifier == "2D_View":
return True
channel_type = getattr(
substance_painter.textureset.ChannelType, map_identifier, None)
if channel_type is None:
return False
if not texture_stack.has_channel(channel_type):
return False
return texture_stack.get_channel(channel_type).is_color()

View file

@ -7,8 +7,7 @@ from openpype.pipeline import publish
import substance_painter.textureset
from openpype.hosts.substancepainter.api.lib import (
get_parsed_export_maps,
strip_template,
has_rgb_channel_in_texture_set
strip_template
)
from openpype.pipeline.create import get_subset_name
from openpype.client import get_asset_by_name
@ -79,6 +78,7 @@ class CollectTextureSet(pyblish.api.InstancePlugin):
# Always include the map identifier
map_identifier = strip_template(template)
suffix += f".{map_identifier}"
image_subset = get_subset_name(
# TODO: The family actually isn't 'texture' currently but for now
# this is only done so the subset name starts with 'texture'
@ -132,9 +132,7 @@ class CollectTextureSet(pyblish.api.InstancePlugin):
# Store color space with the instance
# Note: The extractor will assign it to the representation
colorspace = outputs[0].get("colorSpace")
has_rgb_channel = has_rgb_channel_in_texture_set(
texture_set_name, map_identifier)
if colorspace and has_rgb_channel:
if colorspace:
self.log.debug(f"{image_subset} colorspace: {colorspace}")
image_instance.data["colorspace"] = colorspace