Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Nuke: Prerender Frame Range by default #1699

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions openpype/hosts/nuke/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,8 @@ def add_button_write_to_read(node):
node.addKnob(knob)


def create_write_node(name, data, input=None, prenodes=None, review=True):
def create_write_node(name, data, input=None, prenodes=None,
review=True, linked_knobs=None):
''' Creating write node which is group node

Arguments:
Expand Down Expand Up @@ -465,12 +466,16 @@ def create_write_node(name, data, input=None, prenodes=None, review=True):
GN.addKnob(nuke.Text_Knob('', 'Rendering'))

# Add linked knobs.
linked_knob_names = [
"_grp-start_",
"use_limit", "first", "last",
"_grp-end_",
"Render"
]
linked_knob_names = []

# add input linked knobs and create group only if any input
if linked_knobs:
linked_knob_names.append("_grp-start_")
linked_knob_names.extend(linked_knobs)
linked_knob_names.append("_grp-end_")

linked_knob_names.append("Render")

for name in linked_knob_names:
if "_grp-start_" in name:
knob = nuke.Tab_Knob(
Expand All @@ -481,13 +486,20 @@ def create_write_node(name, data, input=None, prenodes=None, review=True):
"rnd_attr_end", "Rendering attributes", nuke.TABENDGROUP)
GN.addKnob(knob)
else:
link = nuke.Link_Knob("")
link.makeLink(write_node.name(), name)
link.setName(name)
if "Render" in name:
link.setLabel("Render Local")
link.setFlag(0x1000)
GN.addKnob(link)
if "___" in name:
# add devider
GN.addKnob(nuke.Text_Knob(""))
else:
# add linked knob by name
link = nuke.Link_Knob("")
link.makeLink(write_node.name(), name)
link.setName(name)

# make render
if "Render" in name:
link.setLabel("Render Local")
link.setFlag(0x1000)
GN.addKnob(link)

# adding write to read button
add_button_write_to_read(GN)
Expand Down
22 changes: 7 additions & 15 deletions openpype/hosts/nuke/plugins/create/create_write_prerender.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ def process(self):
write_data,
input=selected_node,
prenodes=[],
review=False)
review=False,
linked_knobs=["channels", "___", "first", "last", "use_limit"])

# relinking to collected connections
for i, input in enumerate(inputs):
Expand All @@ -122,19 +123,10 @@ def process(self):
w_node = n
write_node.end()

# add inner write node Tab
write_node.addKnob(nuke.Tab_Knob("WriteLinkedKnobs"))

# linking knobs to group property panel
linking_knobs = ["channels", "___", "first", "last", "use_limit"]
for k in linking_knobs:
if "___" in k:
write_node.addKnob(nuke.Text_Knob(''))
else:
lnk = nuke.Link_Knob(k)
lnk.makeLink(w_node.name(), k)
lnk.setName(k.replace('_', ' ').capitalize())
lnk.clearFlag(nuke.STARTLINE)
write_node.addKnob(lnk)
if self.presets.get("use_range_limit"):
w_node["use_limit"].setValue(True)
w_node["first"].setValue(nuke.root()["first_frame"].value())
w_node["last"].setValue(nuke.root()["last_frame"].value())


return write_node
32 changes: 22 additions & 10 deletions openpype/hosts/nuke/plugins/publish/precollect_writes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import re
from pprint import pformat
import nuke
import pyblish.api
import openpype.api as pype
Expand All @@ -17,6 +18,7 @@ class CollectNukeWrites(pyblish.api.InstancePlugin):

def process(self, instance):
_families_test = [instance.data["family"]] + instance.data["families"]
self.log.debug("_families_test: {}".format(_families_test))

node = None
for x in instance:
Expand Down Expand Up @@ -133,22 +135,29 @@ def process(self, instance):
"outputDir": output_dir,
"ext": ext,
"label": label,
"handleStart": handle_start,
"handleEnd": handle_end,
"frameStart": first_frame + handle_start,
"frameEnd": last_frame - handle_end,
"frameStartHandle": first_frame,
"frameEndHandle": last_frame,
"outputType": output_type,
"colorspace": colorspace,
"deadlineChunkSize": deadlineChunkSize,
"deadlinePriority": deadlinePriority
})

if "prerender" in _families_test:
if self.is_prerender(_families_test):
instance.data.update({
"family": "prerender",
"families": []
"handleStart": 0,
"handleEnd": 0,
"frameStart": first_frame,
"frameEnd": last_frame,
"frameStartHandle": first_frame,
"frameEndHandle": last_frame,
})
else:
instance.data.update({
"handleStart": handle_start,
"handleEnd": handle_end,
"frameStart": first_frame + handle_start,
"frameEnd": last_frame - handle_end,
"frameStartHandle": first_frame,
"frameEndHandle": last_frame,
})

# * Add audio to instance if exists.
Expand All @@ -170,4 +179,7 @@ def process(self, instance):
"filename": api.get_representation_path(repre_doc)
}]

self.log.debug("instance.data: {}".format(instance.data))
self.log.debug("instance.data: {}".format(pformat(instance.data)))

def is_prerender(self, families):
return next((f for f in families if "prerender" in f), None)
23 changes: 17 additions & 6 deletions openpype/hosts/nuke/plugins/publish/validate_rendered_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ class ValidateRenderedFrames(pyblish.api.InstancePlugin):
hosts = ["nuke", "nukestudio"]
actions = [RepairCollectionActionToLocal, RepairCollectionActionToFarm]


def process(self, instance):

for repre in instance.data["representations"]:
Expand All @@ -78,10 +77,10 @@ def process(self, instance):

collection = collections[0]

frame_length = int(
instance.data["frameEndHandle"]
- instance.data["frameStartHandle"] + 1
)
fstartH = instance.data["frameStartHandle"]
fendH = instance.data["frameEndHandle"]

frame_length = int(fendH - fstartH + 1)

if frame_length != 1:
if len(collections) != 1:
Expand All @@ -95,16 +94,28 @@ def process(self, instance):
raise ValidationException(msg)

collected_frames_len = int(len(collection.indexes))
coll_start = min(collection.indexes)
coll_end = max(collection.indexes)

self.log.info("frame_length: {}".format(frame_length))
self.log.info("collected_frames_len: {}".format(
collected_frames_len))
self.log.info("fstartH-fendH: {}-{}".format(fstartH, fendH))
self.log.info(
"coll_start-coll_end: {}-{}".format(coll_start, coll_end))

self.log.info(
"len(collection.indexes): {}".format(collected_frames_len)
)

if ("slate" in instance.data["families"]) \
and (frame_length != collected_frames_len):
collected_frames_len -= 1
fstartH += 1

assert (collected_frames_len == frame_length), (
assert ((collected_frames_len >= frame_length)
and (coll_start <= fstartH)
and (coll_end >= fendH)), (
"{} missing frames. Use repair to render all frames"
).format(__name__)

Expand Down
3 changes: 2 additions & 1 deletion openpype/settings/defaults/project_settings/nuke.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"fpath_template": "{work}/renders/nuke/{subset}/{subset}.{frame}.{ext}"
},
"CreateWritePrerender": {
"fpath_template": "{work}/prerenders/nuke/{subset}/{subset}.{frame}.{ext}"
"fpath_template": "{work}/prerenders/nuke/{subset}/{subset}.{frame}.{ext}",
"use_range_limit": true
}
},
"publish": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
"type": "text",
"key": "fpath_template",
"label": "Path template"
},
{
"type": "boolean",
"key": "use_range_limit",
"label": "Use Frame range limit by default"
}
]
}
Expand Down