code tweaks on has_rgb_channel_in_texture_set function & add publish data into the imageinstance

This commit is contained in:
Kayla Man 2024-01-13 00:15:46 +08:00
parent 6410f381f3
commit 00eb748b4b
3 changed files with 19 additions and 42 deletions

View file

@ -653,45 +653,23 @@ def has_rgb_channel_in_texture_set(texture_set_name, map_identifier):
map_identifier (str): Map identifier
Returns:
colorspace_dict: A dictionary which stores the boolean
value of textures having RGB channels
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
colorspace_dict = {"2D_View": True}
colorspace_dict["BaseColor"] = texture_stack.get_channel(
substance_painter.textureset.ChannelType.BaseColor).is_color()
colorspace_dict["Roughness"] = texture_stack.get_channel(
substance_painter.textureset.ChannelType.Roughness).is_color()
colorspace_dict["Metallic"] = texture_stack.get_channel(
substance_painter.textureset.ChannelType.Metallic).is_color()
colorspace_dict["Height"] = texture_stack.get_channel(
substance_painter.textureset.ChannelType.Height).is_color()
colorspace_dict["Normal"] = texture_stack.get_channel(
substance_painter.textureset.ChannelType.Normal).is_color()
return colorspace_dict.get(map_identifier, False)
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
def texture_set_filtering(texture_set_same, template):
"""Function to check whether some specific textures(e.g. Emissive)
are parts of the texture stack in Substance Painter
Args:
texture_set_same (str): Name of Texture Set
template (str): texture template name
Returns:
texture_filter: A dictionary which stores the boolean
value of whether the texture exist in the channel.
"""
texture_filter = {}
channel_stack = substance_painter.textureset.Stack.from_name(
texture_set_same)
has_emissive = channel_stack.has_channel(
substance_painter.textureset.ChannelType.Emissive)
map_identifier = strip_template(template)
if map_identifier == "Emissive":
texture_filter[map_identifier] = has_emissive
return texture_filter.get(map_identifier, True)
return texture_stack.get_channel(channel_type).is_color()

View file

@ -41,13 +41,11 @@ class CollectTextureSet(pyblish.api.InstancePlugin):
for (texture_set_name, stack_name), template_maps in maps.items():
self.log.info(f"Processing {texture_set_name}/{stack_name}")
for template, outputs in template_maps.items():
if texture_set_filtering(texture_set_name, template):
self.log.info(f"Processing {template}")
self.create_image_instance(
instance, template, outputs,
asset_doc=asset_doc,
texture_set_name=texture_set_name,
stack_name=stack_name)
self.log.info(f"Processing {template}")
self.create_image_instance(instance, template, outputs,
asset_doc=asset_doc,
texture_set_name=texture_set_name,
stack_name=stack_name)
def create_image_instance(self, instance, template, outputs,
asset_doc, texture_set_name, stack_name):

View file

@ -80,6 +80,7 @@ class ValidateOutputMaps(pyblish.api.InstancePlugin):
self.log.warning(f"Disabling texture instance: "
f"{image_instance}")
image_instance.data["active"] = False
image_instance.data["publish"] = False
image_instance.data["integrate"] = False
representation.setdefault("tags", []).append("delete")
continue