Merge pull request #2988 from pypeclub/feature/OP-2983_simple-texture-publishing

Publishing textures for Unreal
This commit is contained in:
Ondřej Samohel 2022-04-05 17:03:48 +02:00 committed by GitHub
commit ef74bfb1d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 130 additions and 5 deletions

View file

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
"""Collect original base name for use in templates."""
from pathlib import Path
import pyblish.api
class CollectOriginalBasename(pyblish.api.InstancePlugin):
"""Collect original file base name."""
order = pyblish.api.CollectorOrder + 0.498
label = "Collect Base Name"
hosts = ["standalonepublisher"]
families = ["simpleUnrealTexture"]
def process(self, instance):
file_name = Path(instance.data["representations"][0]["files"])
instance.data["originalBasename"] = file_name.stem

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Invalid texture name</title>
<description>
## Invalid file name
Submitted file has invalid name:
'{invalid_file}'
### How to repair?
Texture file must adhere to naming conventions for Unreal:
T_{asset}_*.ext
</description>
</error>
</root>

View file

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""Validator for correct file naming."""
import pyblish.api
import openpype.api
import re
from openpype.pipeline import PublishXmlValidationError
class ValidateSimpleUnrealTextureNaming(pyblish.api.InstancePlugin):
label = "Validate Unreal Texture Names"
hosts = ["standalonepublisher"]
families = ["simpleUnrealTexture"]
order = openpype.api.ValidateContentsOrder
regex = "^T_{asset}.*"
def process(self, instance):
file_name = instance.data.get("originalBasename")
self.log.info(file_name)
pattern = self.regex.format(asset=instance.data.get("asset"))
if not re.match(pattern, file_name):
msg = f"Invalid file name {file_name}"
raise PublishXmlValidationError(
self, msg, formatting_data={
"invalid_file": file_name,
"asset": instance.data.get("asset")
})

View file

@ -485,6 +485,11 @@ class IntegrateHeroVersion(pyblish.api.InstancePlugin):
anatomy = instance.context.data["anatomy"]
template_data = copy.deepcopy(instance.data["anatomyData"])
if "originalBasename" in instance.data:
template_data.update({
"originalBasename": instance.data.get("originalBasename")
})
if "folder" in anatomy.templates[template_key]:
anatomy_filled = anatomy.format(template_data)
publish_folder = anatomy_filled[template_key]["folder"]

View file

@ -109,7 +109,8 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
"staticMesh",
"skeletalMesh",
"usdComposition",
"usdOverride"
"usdOverride",
"simpleUnrealTexture"
]
exclude_families = ["clip"]
db_representation_context_keys = [
@ -357,6 +358,8 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
if profile:
template_name = profile["template_name"]
published_representations = {}
for idx, repre in enumerate(instance.data["representations"]):
# reset transfers for next representation
@ -385,6 +388,11 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
if resolution_width:
template_data["fps"] = fps
if "originalBasename" in instance.data:
template_data.update({
"originalBasename": instance.data.get("originalBasename")
})
files = repre['files']
if repre.get('stagingDir'):
stagingdir = repre['stagingDir']
@ -556,6 +564,12 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
repre['published_path'] = dst
self.log.debug("__ dst: {}".format(dst))
if not instance.data.get("publishDir"):
instance.data["publishDir"] = (
anatomy_filled
[template_name]
["folder"]
)
if repre.get("udim"):
repre_context["udim"] = repre.get("udim") # store list

View file

@ -38,8 +38,20 @@
"file": "{subset}_{@version}<_{output}><.{@frame}>.{ext}",
"path": "{@folder}/{@file}"
},
"simpleUnrealTextureHero": {
"folder": "{root[work]}/{project[name]}/{hierarchy}/{asset}/publish/{family}/hero",
"file": "{originalBasename}.{ext}",
"path": "{@folder}/{@file}"
},
"simpleUnrealTexture": {
"folder": "{root[work]}/{project[name]}/{hierarchy}/{asset}/publish/{family}/{@version}",
"file": "{originalBasename}_{@version}.{ext}",
"path": "{@folder}/{@file}"
},
"__dynamic_keys_labels__": {
"maya2unreal": "Maya to Unreal"
"maya2unreal": "Maya to Unreal",
"simpleUnrealTextureHero": "Simple Unreal Texture - Hero",
"simpleUnrealTexture": "Simple Unreal Texture"
}
}
}

View file

@ -180,6 +180,17 @@
"template_name": "render"
},
{
"families": [
"simpleUnrealTexture"
],
"hosts": [
"standalonepublisher"
],
"task_types": [],
"tasks": [],
"template_name": "simpleUnrealTexture"
},
{
"families": [
"staticMesh",
"skeletalMesh"
@ -214,9 +225,22 @@
"animation",
"setdress",
"layout",
"mayaScene"
"mayaScene",
"simpleUnrealTexture"
],
"template_name_profiles": []
"template_name_profiles": [
{
"families": [
"simpleUnrealTexture"
],
"hosts": [
"standalonepublisher"
],
"task_types": [],
"task_names": [],
"template_name": "simpleUnrealTextureHero"
}
]
},
"CleanUp": {
"paterns": [],

View file

@ -133,6 +133,14 @@
],
"help": "Texture files with UDIM together with worfile"
},
"create_simple_unreal_texture": {
"name": "simple_unreal_texture",
"label": "Simple Unreal Texture",
"family": "simpleUnrealTexture",
"icon": "Image",
"defaults": [],
"help": "Texture files with Unreal naming convention"
},
"__dynamic_keys_labels__": {
"create_workfile": "Workfile",
"create_model": "Model",
@ -145,7 +153,8 @@
"create_matchmove": "Matchmove",
"create_render": "Render",
"create_mov_batch": "Batch Mov",
"create_texture_batch": "Batch Texture"
"create_texture_batch": "Batch Texture",
"create_simple_unreal_texture": "Simple Unreal Texture"
}
},
"publish": {