This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2917 from simonebarbieri/feature/unreal-render_pu…
…blishing
- Loading branch information
Showing
9 changed files
with
254 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
openpype/hosts/unreal/plugins/publish/collect_remove_marked.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import pyblish.api | ||
|
||
|
||
class CollectRemoveMarked(pyblish.api.ContextPlugin): | ||
"""Remove marked data | ||
Remove instances that have 'remove' in their instance.data | ||
""" | ||
|
||
order = pyblish.api.CollectorOrder + 0.499 | ||
label = 'Remove Marked Instances' | ||
|
||
def process(self, context): | ||
|
||
self.log.debug(context) | ||
# make ftrack publishable | ||
instances_to_remove = [] | ||
for instance in context: | ||
if instance.data.get('remove'): | ||
instances_to_remove.append(instance) | ||
|
||
for instance in instances_to_remove: | ||
context.remove(instance) |
103 changes: 103 additions & 0 deletions
103
openpype/hosts/unreal/plugins/publish/collect_render_instances.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
from pathlib import Path | ||
import unreal | ||
|
||
import pyblish.api | ||
from openpype.hosts.unreal.api import pipeline | ||
|
||
|
||
class CollectRenderInstances(pyblish.api.InstancePlugin): | ||
""" This collector will try to find all the rendered frames. | ||
""" | ||
order = pyblish.api.CollectorOrder | ||
hosts = ["unreal"] | ||
families = ["render"] | ||
label = "Collect Render Instances" | ||
|
||
def process(self, instance): | ||
self.log.debug("Preparing Rendering Instances") | ||
|
||
context = instance.context | ||
|
||
data = instance.data | ||
data['remove'] = True | ||
|
||
ar = unreal.AssetRegistryHelpers.get_asset_registry() | ||
|
||
sequence = ar.get_asset_by_object_path( | ||
data.get('sequence')).get_asset() | ||
|
||
sequences = [{ | ||
"sequence": sequence, | ||
"output": data.get('output'), | ||
"frame_range": ( | ||
data.get('frameStart'), data.get('frameEnd')) | ||
}] | ||
|
||
for s in sequences: | ||
self.log.debug(f"Processing: {s.get('sequence').get_name()}") | ||
subscenes = pipeline.get_subsequences(s.get('sequence')) | ||
|
||
if subscenes: | ||
for ss in subscenes: | ||
sequences.append({ | ||
"sequence": ss.get_sequence(), | ||
"output": (f"{s.get('output')}/" | ||
f"{ss.get_sequence().get_name()}"), | ||
"frame_range": ( | ||
ss.get_start_frame(), ss.get_end_frame() - 1) | ||
}) | ||
else: | ||
# Avoid creating instances for camera sequences | ||
if "_camera" not in s.get('sequence').get_name(): | ||
seq = s.get('sequence') | ||
seq_name = seq.get_name() | ||
|
||
new_instance = context.create_instance( | ||
f"{data.get('subset')}_" | ||
f"{seq_name}") | ||
new_instance[:] = seq_name | ||
|
||
new_data = new_instance.data | ||
|
||
new_data["asset"] = seq_name | ||
new_data["setMembers"] = seq_name | ||
new_data["family"] = "render" | ||
new_data["families"] = ["render", "review"] | ||
new_data["parent"] = data.get("parent") | ||
new_data["subset"] = f"{data.get('subset')}_{seq_name}" | ||
new_data["level"] = data.get("level") | ||
new_data["output"] = s.get('output') | ||
new_data["fps"] = seq.get_display_rate().numerator | ||
new_data["frameStart"] = s.get('frame_range')[0] | ||
new_data["frameEnd"] = s.get('frame_range')[1] | ||
new_data["sequence"] = seq.get_path_name() | ||
new_data["master_sequence"] = data["master_sequence"] | ||
new_data["master_level"] = data["master_level"] | ||
|
||
self.log.debug(f"new instance data: {new_data}") | ||
|
||
project_dir = unreal.Paths.project_dir() | ||
render_dir = (f"{project_dir}/Saved/MovieRenders/" | ||
f"{s.get('output')}") | ||
render_path = Path(render_dir) | ||
|
||
frames = [] | ||
|
||
for x in render_path.iterdir(): | ||
if x.is_file() and x.suffix == '.png': | ||
frames.append(str(x.name)) | ||
|
||
if "representations" not in new_instance.data: | ||
new_instance.data["representations"] = [] | ||
|
||
repr = { | ||
'frameStart': s.get('frame_range')[0], | ||
'frameEnd': s.get('frame_range')[1], | ||
'name': 'png', | ||
'ext': 'png', | ||
'files': frames, | ||
'stagingDir': render_dir, | ||
'tags': ['review'] | ||
} | ||
new_instance.data["representations"].append(repr) |
41 changes: 41 additions & 0 deletions
41
openpype/hosts/unreal/plugins/publish/validate_sequence_frames.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import clique | ||
|
||
import pyblish.api | ||
|
||
|
||
class ValidateSequenceFrames(pyblish.api.InstancePlugin): | ||
"""Ensure the sequence of frames is complete | ||
The files found in the folder are checked against the frameStart and | ||
frameEnd of the instance. If the first or last file is not | ||
corresponding with the first or last frame it is flagged as invalid. | ||
""" | ||
|
||
order = pyblish.api.ValidatorOrder | ||
label = "Validate Sequence Frames" | ||
families = ["render"] | ||
hosts = ["unreal"] | ||
optional = True | ||
|
||
def process(self, instance): | ||
representations = instance.data.get("representations") | ||
for repr in representations: | ||
patterns = [clique.PATTERNS["frames"]] | ||
collections, remainder = clique.assemble( | ||
repr["files"], minimum_items=1, patterns=patterns) | ||
|
||
assert not remainder, "Must not have remainder" | ||
assert len(collections) == 1, "Must detect single collection" | ||
collection = collections[0] | ||
frames = list(collection.indexes) | ||
|
||
current_range = (frames[0], frames[-1]) | ||
required_range = (instance.data["frameStart"], | ||
instance.data["frameEnd"]) | ||
|
||
if current_range != required_range: | ||
raise ValueError(f"Invalid frame range: {current_range} - " | ||
f"expected: {required_range}") | ||
|
||
missing = collection.holes().indexes | ||
assert not missing, "Missing frames: %s" % (missing,) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.