From 1994a11fe1a259707d58e369d82cdf77bb865e7e Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 11:48:36 +0200 Subject: [PATCH 01/11] modified collect instance --- .../plugins/publish/collect_instances.py | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py index 9cbfb61550..0008248405 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py @@ -20,21 +20,35 @@ class CollectInstances(pyblish.api.ContextPlugin): json.dumps(workfile_instances, indent=4) )) + filtered_instance_data = [] + # Check if there is any created instance + any_created_instance = False # Backwards compatibility for workfiles that already have review # instance in metadata. review_instance_exist = False for instance_data in workfile_instances: - if instance_data["family"] == "review": + family = instance_data["family"] + if family == "review": review_instance_exist = True - break + + elif family in ("renderPass", "renderLayer"): + any_created_instance = True + + else: + self.log.info("Unknown family \"{}\". Skipping {}".format( + family, json.dumps(instance_data, indent=4) + )) + continue + + filtered_instance_data.append(instance_data) # Fake review instance if review was not found in metadata families if not review_instance_exist: - workfile_instances.append( + filtered_instance_data.append( self._create_review_instance_data(context) ) - for instance_data in workfile_instances: + for instance_data in filtered_instance_data: instance_data["fps"] = context.data["sceneFps"] # Store workfile instance data to instance data @@ -42,8 +56,11 @@ class CollectInstances(pyblish.api.ContextPlugin): # Global instance data modifications # Fill families family = instance_data["family"] + families = [family] + if family != "review": + families.append("review") # Add `review` family for thumbnail integration - instance_data["families"] = [family, "review"] + instance_data["families"] = families # Instance name subset_name = instance_data["subset"] @@ -78,7 +95,7 @@ class CollectInstances(pyblish.api.ContextPlugin): # Project name from workfile context project_name = context.data["workfile_context"]["project"] # Host name from environment variable - host_name = os.environ["AVALON_APP"] + host_name = context.data["hostName"] # Use empty variant value variant = "" task_name = io.Session["AVALON_TASK"] @@ -106,12 +123,6 @@ class CollectInstances(pyblish.api.ContextPlugin): instance = self.create_render_pass_instance( context, instance_data ) - else: - raise AssertionError( - "Instance with unknown family \"{}\": {}".format( - family, instance_data - ) - ) if instance is None: continue From a29a7a67f23b7a132b099b7c1487084403ad7b1c Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 11:59:27 +0200 Subject: [PATCH 02/11] added collector which collects renderScene family --- .../plugins/publish/collect_scene_render.py | 104 ++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py new file mode 100644 index 0000000000..2dcdab5c69 --- /dev/null +++ b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py @@ -0,0 +1,104 @@ +import json +import copy +import pyblish.api +from avalon import io + +from openpype.lib import get_subset_name_with_asset_doc + + +class CollectRenderScene(pyblish.api.ContextPlugin): + """Collect instance which renders whole scene in PNG. + + Creates instance with family 'renderScene' which will have all layers + to render which will be composite into one result. The instance is not + collected from scene. + + Scene will be rendered with all visible layers similar way like review is. + + Instance is disabled if there are any created instances of 'renderLayer' + or 'renderPass'. That is because it is expected that this instance is + used as lazy publish of TVPaint file. + + Subset name is created similar way like 'renderLayer' family. It can use + `renderPass` and `renderLayer` keys which can be set using settings and + `variant` is filled using `renderPass` value. + """ + label = "Collect Render Scene" + order = pyblish.api.CollectorOrder - 0.4 + hosts = ["tvpaint"] + + # Settings attributes + enabled = False + # Value of 'renderLayer' for subset name template + render_layer_name = "Scene" + # Value of 'renderPass' for subset name template + render_pass_name = "Beauty" + + def process(self, context): + # Check if there are created instances of renderPass and renderLayer + # - that will define if renderScene instance is enabled after + # collection + any_created_instance = False + for instance in context: + family = instance.data["family"] + if family in ("renderPass", "renderLayer"): + any_created_instance = True + break + + # Global instance data modifications + # Fill families + family = "renderScene" + # Add `review` family for thumbnail integration + families = [family, "review"] + + # Collect asset doc to get asset id + # - not sure if it's good idea to require asset id in + # get_subset_name? + asset_name = context.data["workfile_context"]["asset"] + asset_doc = io.find_one({ + "type": "asset", + "name": asset_name + }) + + # Project name from workfile context + project_name = context.data["workfile_context"]["project"] + # Host name from environment variable + host_name = context.data["hostName"] + # Variant is using render pass name + variant = self.render_pass_name + dynamic_data = { + "renderLayer": self.render_layer_name, + "renderPass": self.render_pass_name, + } + task_name = io.Session["AVALON_TASK"] + subset_name = get_subset_name_with_asset_doc( + family, + variant, + task_name, + asset_doc, + project_name, + host_name, + dynamic_data=dynamic_data + ) + + instance_data = { + "family": family, + "families": families, + "fps": context.data["sceneFps"], + "name": subset_name, + "label": "{} [{}-{}]".format( + subset_name, + context.data["sceneMarkIn"] + 1, + context.data["sceneMarkOut"] + 1 + ), + "active": not any_created_instance, + "publish": not any_created_instance, + "representations": [], + "layers": copy.deepcopy(context.data["layersData"]) + } + + instance = context.create_instance(**instance_data) + + self.log.debug("Created instance: {}\n{}".format( + instance, json.dumps(instance.data, indent=4) + )) From 288fa288c1dcca485febdf588becac109e76daa5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 12:01:53 +0200 Subject: [PATCH 03/11] added renderScene into other tvpaint plugins related to the renderScene logic --- openpype/hosts/tvpaint/plugins/publish/extract_sequence.py | 6 +++--- .../tvpaint/plugins/publish/validate_layers_visibility.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py b/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py index 139dabadee..73daf60567 100644 --- a/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py +++ b/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py @@ -18,7 +18,7 @@ from openpype.hosts.tvpaint.lib import ( class ExtractSequence(pyblish.api.Extractor): label = "Extract Sequence" hosts = ["tvpaint"] - families = ["review", "renderPass", "renderLayer"] + families = ["review", "renderPass", "renderLayer", "renderScene"] # Modifiable with settings review_bg = [255, 255, 255, 255] @@ -159,7 +159,7 @@ class ExtractSequence(pyblish.api.Extractor): # Fill tags and new families tags = [] - if family_lowered in ("review", "renderlayer"): + if family_lowered in ("review", "renderlayer", "renderScene"): tags.append("review") # Sequence of one frame @@ -185,7 +185,7 @@ class ExtractSequence(pyblish.api.Extractor): instance.data["representations"].append(new_repre) - if family_lowered in ("renderpass", "renderlayer"): + if family_lowered in ("renderpass", "renderlayer", "renderscene"): # Change family to render instance.data["family"] = "render" diff --git a/openpype/hosts/tvpaint/plugins/publish/validate_layers_visibility.py b/openpype/hosts/tvpaint/plugins/publish/validate_layers_visibility.py index 7ea0587b8f..d3a04cc69f 100644 --- a/openpype/hosts/tvpaint/plugins/publish/validate_layers_visibility.py +++ b/openpype/hosts/tvpaint/plugins/publish/validate_layers_visibility.py @@ -8,7 +8,7 @@ class ValidateLayersVisiblity(pyblish.api.InstancePlugin): label = "Validate Layers Visibility" order = pyblish.api.ValidatorOrder - families = ["review", "renderPass", "renderLayer"] + families = ["review", "renderPass", "renderLayer", "renderScene"] def process(self, instance): layer_names = set() From 82d2a4be19c011378f898020a61b8668c888d109 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 14:19:42 +0200 Subject: [PATCH 04/11] added settings and pass is now defined only by plugin --- .../plugins/publish/collect_scene_render.py | 15 ++++++------ .../defaults/project_settings/tvpaint.json | 4 ++++ .../schema_project_tvpaint.json | 24 +++++++++++++++++++ 3 files changed, 36 insertions(+), 7 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py index 2dcdab5c69..dc9c63f3bd 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py @@ -27,12 +27,13 @@ class CollectRenderScene(pyblish.api.ContextPlugin): order = pyblish.api.CollectorOrder - 0.4 hosts = ["tvpaint"] + # Value of 'render_pass' in subset name template + render_pass = "beauty" + # Settings attributes enabled = False - # Value of 'renderLayer' for subset name template - render_layer_name = "Scene" - # Value of 'renderPass' for subset name template - render_pass_name = "Beauty" + # Value of 'render_layer' and 'variant' in subset name template + render_layer = "Main" def process(self, context): # Check if there are created instances of renderPass and renderLayer @@ -65,10 +66,10 @@ class CollectRenderScene(pyblish.api.ContextPlugin): # Host name from environment variable host_name = context.data["hostName"] # Variant is using render pass name - variant = self.render_pass_name + variant = self.render_layer dynamic_data = { - "renderLayer": self.render_layer_name, - "renderPass": self.render_pass_name, + "render_layer": self.render_layer, + "render_pass": self.render_pass } task_name = io.Session["AVALON_TASK"] subset_name = get_subset_name_with_asset_doc( diff --git a/openpype/settings/defaults/project_settings/tvpaint.json b/openpype/settings/defaults/project_settings/tvpaint.json index 46beeb85b9..88b5a598cd 100644 --- a/openpype/settings/defaults/project_settings/tvpaint.json +++ b/openpype/settings/defaults/project_settings/tvpaint.json @@ -1,6 +1,10 @@ { "stop_timer_on_application_exit": false, "publish": { + "CollectRenderScene": { + "enabled": false, + "render_layer": "Main" + }, "ExtractSequence": { "review_bg": [ 255, diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json index 97462a8b62..e1166dc2bb 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json @@ -16,6 +16,30 @@ "key": "publish", "label": "Publish plugins", "children": [ + { + "type": "dict", + "collapsible": true, + "key": "CollectRenderScene", + "label": "Collect Render Scene", + "is_group": true, + "checkbox_key": "enabled", + "children": [ + { + "type": "boolean", + "key": "enabled", + "label": "Enabled" + }, + { + "type": "label", + "label": "It is possible to fill 'render_layer' or 'variant' in subset name template with custom value. Value of 'render_pass' is \"Beauty\"." + }, + { + "type": "text", + "key": "render_layer", + "label": "Render Layer" + } + ] + }, { "type": "dict", "collapsible": true, From 7ce9095115653f0b0ef9e0f5faf26e4d9a24c2fd Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 14:27:23 +0200 Subject: [PATCH 05/11] change order --- openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py index dc9c63f3bd..38dc431778 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py @@ -24,7 +24,7 @@ class CollectRenderScene(pyblish.api.ContextPlugin): `variant` is filled using `renderPass` value. """ label = "Collect Render Scene" - order = pyblish.api.CollectorOrder - 0.4 + order = pyblish.api.CollectorOrder - 0.39 hosts = ["tvpaint"] # Value of 'render_pass' in subset name template From 1bde9c0fa96c3b20101316ceedb0c84b07673882 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 14:30:45 +0200 Subject: [PATCH 06/11] remove unused variable --- .../hosts/tvpaint/plugins/publish/collect_instances.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py index 0008248405..5e8d13592c 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_instances.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_instances.py @@ -21,8 +21,6 @@ class CollectInstances(pyblish.api.ContextPlugin): )) filtered_instance_data = [] - # Check if there is any created instance - any_created_instance = False # Backwards compatibility for workfiles that already have review # instance in metadata. review_instance_exist = False @@ -31,10 +29,7 @@ class CollectInstances(pyblish.api.ContextPlugin): if family == "review": review_instance_exist = True - elif family in ("renderPass", "renderLayer"): - any_created_instance = True - - else: + elif family not in ("renderPass", "renderLayer"): self.log.info("Unknown family \"{}\". Skipping {}".format( family, json.dumps(instance_data, indent=4) )) From f3f5007af5b3fdc4512adc2fdba85b9a4030e5a0 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 15:47:18 +0200 Subject: [PATCH 07/11] added asset and task on instance data --- .../tvpaint/plugins/publish/collect_scene_render.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py index 38dc431778..df3f715853 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py @@ -55,7 +55,8 @@ class CollectRenderScene(pyblish.api.ContextPlugin): # Collect asset doc to get asset id # - not sure if it's good idea to require asset id in # get_subset_name? - asset_name = context.data["workfile_context"]["asset"] + workfile_context = context.data["workfile_context"] + asset_name = workfile_context["asset"] asset_doc = io.find_one({ "type": "asset", "name": asset_name @@ -71,7 +72,8 @@ class CollectRenderScene(pyblish.api.ContextPlugin): "render_layer": self.render_layer, "render_pass": self.render_pass } - task_name = io.Session["AVALON_TASK"] + + task_name = workfile_context["task"] subset_name = get_subset_name_with_asset_doc( family, variant, @@ -95,7 +97,9 @@ class CollectRenderScene(pyblish.api.ContextPlugin): "active": not any_created_instance, "publish": not any_created_instance, "representations": [], - "layers": copy.deepcopy(context.data["layersData"]) + "layers": copy.deepcopy(context.data["layersData"]), + "asset": asset_name, + "task": task_name } instance = context.create_instance(**instance_data) From 486ccff38f6837465698b107c6682ec4e586415b Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 15:52:56 +0200 Subject: [PATCH 08/11] added missing subset key --- openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py | 1 + 1 file changed, 1 insertion(+) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py index df3f715853..9d5c4dbb62 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py @@ -88,6 +88,7 @@ class CollectRenderScene(pyblish.api.ContextPlugin): "family": family, "families": families, "fps": context.data["sceneFps"], + "subset": subset_name, "name": subset_name, "label": "{} [{}-{}]".format( subset_name, From ee827e8dd2e3ec5209969f33392c0dea5c952195 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 16:02:19 +0200 Subject: [PATCH 09/11] fix case family --- openpype/hosts/tvpaint/plugins/publish/extract_sequence.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py b/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py index 73daf60567..d4fd1dff4b 100644 --- a/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py +++ b/openpype/hosts/tvpaint/plugins/publish/extract_sequence.py @@ -159,7 +159,7 @@ class ExtractSequence(pyblish.api.Extractor): # Fill tags and new families tags = [] - if family_lowered in ("review", "renderlayer", "renderScene"): + if family_lowered in ("review", "renderlayer", "renderscene"): tags.append("review") # Sequence of one frame From 81bbdc972f31e4dc5d7c25f6e3a4a136b1ef220d Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 16:05:24 +0200 Subject: [PATCH 10/11] fix family used to get subset name --- openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py index 9d5c4dbb62..0af9a9a400 100644 --- a/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py +++ b/openpype/hosts/tvpaint/plugins/publish/collect_scene_render.py @@ -75,7 +75,7 @@ class CollectRenderScene(pyblish.api.ContextPlugin): task_name = workfile_context["task"] subset_name = get_subset_name_with_asset_doc( - family, + "render", variant, task_name, asset_doc, From 8c1fbf88d5e431156254583380ff24ec251832e5 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Fri, 1 Apr 2022 16:20:15 +0200 Subject: [PATCH 11/11] added more info into label --- .../schemas/projects_schema/schema_project_tvpaint.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json index e1166dc2bb..20fe5b0855 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_tvpaint.json @@ -31,7 +31,7 @@ }, { "type": "label", - "label": "It is possible to fill 'render_layer' or 'variant' in subset name template with custom value. Value of 'render_pass' is \"Beauty\"." + "label": "It is possible to fill 'render_layer' or 'variant' in subset name template with custom value.
- value of 'render_pass' is always \"beauty\"." }, { "type": "text",