mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #512 from pypeclub/feature/tiled-exr-to-scanline
Maya: Tiled EXRs to scanline EXRs render option
This commit is contained in:
commit
f2ed187ebd
4 changed files with 104 additions and 2 deletions
89
pype/plugins/global/publish/extract_scanline_exr.py
Normal file
89
pype/plugins/global/publish/extract_scanline_exr.py
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
"""Convert exrs in representation to tiled exrs usin oiio tools."""
|
||||
import os
|
||||
import shutil
|
||||
|
||||
import pyblish.api
|
||||
import pype.api
|
||||
import pype.lib
|
||||
|
||||
|
||||
class ExtractScanlineExr(pyblish.api.InstancePlugin):
|
||||
"""Convert tiled EXRs to scanline using OIIO tool."""
|
||||
|
||||
label = "Extract Scanline EXR"
|
||||
hosts = ["shell"]
|
||||
order = pyblish.api.ExtractorOrder
|
||||
families = ["imagesequence", "render", "render2d", "source"]
|
||||
|
||||
def process(self, instance):
|
||||
"""Plugin entry point."""
|
||||
# get representation and loop them
|
||||
representations = instance.data["representations"]
|
||||
|
||||
representations_new = []
|
||||
|
||||
for repre in representations:
|
||||
self.log.info(
|
||||
"Processing representation {}".format(repre.get("name")))
|
||||
tags = repre.get("tags", [])
|
||||
if "toScanline" not in tags:
|
||||
self.log.info(" - missing toScanline tag")
|
||||
continue
|
||||
|
||||
# run only on exrs
|
||||
if repre.get("ext") != "exr":
|
||||
self.log.info("- not EXR files")
|
||||
continue
|
||||
|
||||
if not isinstance(repre['files'], (list, tuple)):
|
||||
input_files = [repre['files']]
|
||||
self.log.info("We have a single frame")
|
||||
else:
|
||||
input_files = repre['files']
|
||||
self.log.info("We have a sequence")
|
||||
|
||||
stagingdir = os.path.normpath(repre.get("stagingDir"))
|
||||
|
||||
oiio_tool_path = os.getenv("PYPE_OIIO_PATH", "")
|
||||
|
||||
for file in input_files:
|
||||
|
||||
original_name = os.path.join(stagingdir, file)
|
||||
temp_name = os.path.join(stagingdir, "__{}".format(file))
|
||||
# move original render to temp location
|
||||
shutil.move(original_name, temp_name)
|
||||
oiio_cmd = []
|
||||
oiio_cmd.append(oiio_tool_path)
|
||||
oiio_cmd.append(
|
||||
os.path.join(stagingdir, temp_name)
|
||||
)
|
||||
oiio_cmd.append("--scanline")
|
||||
oiio_cmd.append("-o")
|
||||
oiio_cmd.append(os.path.join(stagingdir, original_name))
|
||||
|
||||
subprocess_exr = " ".join(oiio_cmd)
|
||||
self.log.info(f"running: {subprocess_exr}")
|
||||
pype.api.subprocess(subprocess_exr)
|
||||
|
||||
# raise error if there is no ouptput
|
||||
if not os.path.exists(os.path.join(stagingdir, original_name)):
|
||||
self.log.error(
|
||||
("File {} was not converted "
|
||||
"by oiio tool!").format(original_name))
|
||||
raise AssertionError("OIIO tool conversion failed")
|
||||
else:
|
||||
try:
|
||||
os.remove(temp_name)
|
||||
except OSError as e:
|
||||
self.log.warning("Unable to delete temp file")
|
||||
self.log.warning(e)
|
||||
|
||||
repre['name'] = 'exr'
|
||||
try:
|
||||
repre['tags'].remove('toScanline')
|
||||
except ValueError:
|
||||
# no `toScanline` tag present
|
||||
pass
|
||||
|
||||
instance.data["representations"] += representations_new
|
||||
|
|
@ -194,7 +194,8 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
|
|||
"slate": ["slateFrame"],
|
||||
"review": ["lutPath"],
|
||||
"render2d": ["bakeScriptPath", "bakeRenderPath",
|
||||
"bakeWriteNodeName", "version"]
|
||||
"bakeWriteNodeName", "version"],
|
||||
"renderlayer": ["convertToScanline"]
|
||||
}
|
||||
|
||||
# list of family names to transfer to new family if present
|
||||
|
|
@ -493,6 +494,11 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
|
|||
"tags": ["review"] if preview else []
|
||||
}
|
||||
|
||||
# support conversion from tiled to scanline
|
||||
if instance_data.get("convertToScanline"):
|
||||
self.log.info("Adding scanline conversion.")
|
||||
rep["tags"].append("toScanline")
|
||||
|
||||
# poor man exclusion
|
||||
if ext in self.skip_integration_repre_list:
|
||||
rep["tags"].append("delete")
|
||||
|
|
@ -583,6 +589,11 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
|
|||
if instance.get("multipartExr", False):
|
||||
rep["tags"].append("multipartExr")
|
||||
|
||||
# support conversion from tiled to scanline
|
||||
if instance.get("convertToScanline"):
|
||||
self.log.info("Adding scanline conversion.")
|
||||
rep["tags"].append("toScanline")
|
||||
|
||||
representations.append(rep)
|
||||
|
||||
self._solve_families(instance, preview)
|
||||
|
|
|
|||
|
|
@ -188,6 +188,7 @@ class CreateRender(avalon.maya.Creator):
|
|||
self.data["tileRendering"] = False
|
||||
self.data["tilesX"] = 2
|
||||
self.data["tilesY"] = 2
|
||||
self.data["convertToScanline"] = False
|
||||
# Disable for now as this feature is not working yet
|
||||
# self.data["assScene"] = False
|
||||
|
||||
|
|
|
|||
|
|
@ -246,7 +246,8 @@ class CollectMayaRender(pyblish.api.ContextPlugin):
|
|||
"tileRendering": render_instance.data.get("tileRendering") or False, # noqa: E501
|
||||
"tilesX": render_instance.data.get("tilesX") or 2,
|
||||
"tilesY": render_instance.data.get("tilesY") or 2,
|
||||
"priority": render_instance.data.get("priority")
|
||||
"priority": render_instance.data.get("priority"),
|
||||
"convertToScanline": render_instance.data.get("convertToScanline") or False # noqa: E501
|
||||
}
|
||||
|
||||
# Apply each user defined attribute as data
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue