added some dosctrings, comments and descriptions

This commit is contained in:
Jakub Trllo 2023-02-15 18:26:31 +01:00
parent 8441a5c54b
commit 7d7c8a8d74
2 changed files with 63 additions and 1 deletions

View file

@ -9,6 +9,14 @@ from openpype.hosts.tvpaint.api.lib import get_groups_data
class TVPaintLegacyConverted(SubsetConvertorPlugin):
"""Conversion of legacy instances in scene to new creators.
This convertor handles only instances created by core creators.
All instances that would be created using auto-creators are removed as at
the moment of finding them would there already be existing instances.
"""
identifier = "tvpaint.legacy.converter"
def find_instances(self):
@ -68,6 +76,7 @@ class TVPaintLegacyConverted(SubsetConvertorPlugin):
if not render_layers:
return
# Look for possible existing render layers in scene
render_layers_by_group_id = {}
for instance in current_instances:
if instance.get("creator_identifier") == "render.layer":
@ -80,22 +89,30 @@ class TVPaintLegacyConverted(SubsetConvertorPlugin):
}
for render_layer in render_layers:
group_id = render_layer.pop("group_id")
# Just remove legacy instance if group is already occupied
if group_id in render_layers_by_group_id:
render_layer["keep"] = False
continue
# Add identifier
render_layer["creator_identifier"] = "render.layer"
# Change 'uuid' to 'instance_id'
render_layer["instance_id"] = render_layer.pop("uuid")
# Fill creator attributes
render_layer["creator_attributes"] = {
"group_id": group_id
}
render_layer["family"] = "render"
group = groups_by_id[group_id]
# Use group name for variant
group["variant"] = group["name"]
def _convert_render_passes(self, render_passes, current_instances):
if not render_passes:
return
# Render passes must have available render layers so we look for render
# layers first
# - '_convert_render_layers' must be called before this method
render_layers_by_group_id = {}
for instance in current_instances:
if instance.get("creator_identifier") == "render.layer":
@ -119,6 +136,7 @@ class TVPaintLegacyConverted(SubsetConvertorPlugin):
render_pass["variant"] = render_pass.pop("pass")
render_pass.pop("renderlayer")
# Rest of instances are just marked for deletion
def _convert_render_scenes(self, render_scenes, current_instances):
for render_scene in render_scenes:
render_scene["keep"] = False

View file

@ -25,6 +25,10 @@ default 'color' blend more. In that case it is not recommended to use this
workflow at all as other blend modes may affect all layers in clip which can't
be done.
There is special case for simple publishing of scene which is called
'render.scene'. That will use all visible layers and render them as one big
sequence.
Todos:
Add option to extract marked layers and passes as json output format for
AfterEffects.
@ -53,9 +57,42 @@ from openpype.hosts.tvpaint.api.lib import (
execute_george_through_file,
)
RENDER_LAYER_DETAILED_DESCRIPTIONS = (
"""Render Layer is "a group of TVPaint layers"
Be aware Render Layer <b>is not</b> TVPaint layer.
All TVPaint layers in the scene with the color group id are rendered in the
beauty pass. To create sub passes use Render Layer creator which is
dependent on existence of render layer instance.
The group can represent an asset (tree) or different part of scene that consist
of one or more TVPaint layers that can be used as single item during
compositing (for example).
In some cases may be needed to have sub parts of the layer. For example 'Bob'
could be Render Layer which has 'Arm', 'Head' and 'Body' as Render Passes.
"""
)
RENDER_PASS_DETAILED_DESCRIPTIONS = (
"""Render Pass is sub part of Rende Layer.
Render Pass can consist of one or more TVPaint layers. Render Layers must
belong to a Render Layer. Marker TVPaint layers will change it's group color
to match group color of Render Layer.
"""
)
class CreateRenderlayer(TVPaintCreator):
"""Mark layer group as one instance."""
"""Mark layer group as Render layer instance.
All TVPaint layers in the scene with the color group id are rendered in the
beauty pass. To create sub passes use Render Layer creator which is
dependent on existence of render layer instance.
"""
label = "Render Layer"
family = "render"
@ -68,10 +105,15 @@ class CreateRenderlayer(TVPaintCreator):
"tv_layercolor \"setcolor\""
" {clip_id} {group_id} {r} {g} {b} \"{name}\""
)
# Order to be executed before Render Pass creator
order = 90
description = "Mark TVPaint color group as one Render Layer."
detailed_description = RENDER_LAYER_DETAILED_DESCRIPTIONS
# Settings
# - Default render pass name for beauty
render_pass = "beauty"
# - Mark by default instance for review
mark_for_review = True
def get_dynamic_data(
@ -271,6 +313,8 @@ class CreateRenderPass(TVPaintCreator):
identifier = "render.pass"
label = "Render Pass"
icon = "fa5.image"
description = "Mark selected TVPaint layers as pass of Render Layer."
detailed_description = RENDER_PASS_DETAILED_DESCRIPTIONS
order = CreateRenderlayer.order + 10