def _set_lut_1d(proc, nodename, size = 1024): # TODO: Use allocation vars also # Make noop ramp def gen_noop_ramp(size): size_minus_one = float(size-1) for x in range(size): val = x/size_minus_one for i in range(3): yield val ramp_raw = gen_noop_ramp(size = size) # Apply transform # TODO: Make applyRGB accept an iterable, rather than requiring a # list, to avoid making the intermediate list ramp_transformed = proc.applyRGB(ramp_raw) # Set LUT type and size, then LUT values setStringProperty("%s.lut.type" % nodename, ["RGB"], False) setIntProperty("%s.lut.size" % nodename, [size], False) setFloatProperty("%s.lut.lut" % nodename, ramp_transformed, True) # Activate setIntProperty("%s.lut.active" % nodename, [1], False)
def set_noop(nodename): """Just ensure sure the LUT is deactivated, in case source changes from switch from a non-noop to a noop processor """ is_active = False setIntProperty("%s.lut.active" % nodename, [is_active], False)
def toggle_media(self, var): """ Swap between Shotgun format media (frames/movie). Also handles the case where we're not looking at Shotgun media, by bailing out gracefully. """ source_node = commands.closestNodesOfType("RVFileSource")[0] try: media_type = commands.getStringProperty("%s.tracking.mediaType" % source_node)[0] except: # if the previous command throws an exception, we aren't # looking at Shotgun sources pass else: mu = """ require shotgun_mode; shotgun_mode.theMode().swapMediaFromInfo("%s", "%s"); """ if str(media_type.lower()) == "dnxhd": runtime.eval(mu % ("Frames", source_node), ["shotgun_mode"]) else: runtime.eval(mu % ("DNXHD", source_node), ["shotgun_mode"]) # recheck our current media_type since it's possible the # media type doesn't exist and therefore wouldn't have # changed media_type = commands.getStringProperty("%s.tracking.mediaType" % source_node)[0] if str(media_type).lower() == "frames": # make sure our alexa node is active commands.setIntProperty("#LinearToAlexaLogC.node.active", [1], True) else: # make sure our alexa node is not active commands.setIntProperty("#LinearToAlexaLogC.node.active", [0], True) # and display some feedback so the user knows what's happening extra_commands.displayFeedback("View %s" % media_type.upper(), 5.0)
def _set_lut_1d(proc, nodename, size=1024): # TODO: Use allocation vars also # Make noop ramp def gen_noop_ramp(size): size_minus_one = float(size - 1) for x in range(size): val = x / size_minus_one for i in range(3): yield val ramp_raw = gen_noop_ramp(size=size) # Apply transform # TODO: Make applyRGB accept an iterable, rather than requiring a # list, to avoid making the intermediate list ramp_transformed = proc.applyRGB(ramp_raw) # Set LUT type and size, then LUT values setStringProperty("%s.lut.type" % nodename, ["RGB"], False) setIntProperty("%s.lut.size" % nodename, [size], False) setFloatProperty("%s.lut.lut" % nodename, ramp_transformed, True) # Activate setIntProperty("%s.lut.active" % nodename, [1], False)
def F(): try: if checkbox.isChecked(): commands.setIntProperty(prop, [1], True) else: commands.setIntProperty(prop, [0], True) except Exception, e: print e
def _create_item(it, context=None): context = context or {} range_to_read = it.trimmed_range() if not range_to_read: raise otio.exceptions.OTIOError("No valid range on clip: {0}.".format( str(it))) new_media = _create_media_reference(it, context) if not new_media: kind = "smptebars" if isinstance(it, otio.schema.Gap): kind = "blank" new_media = [_create_movieproc(range_to_read, kind)] try: src = commands.addSourceVerbose(new_media) except Exception as e: # Perhaps the media was missing, if so, lets load an error # source print('ERROR: {}'.format(e)) error_media = _create_movieproc(range_to_read, 'smptebars') src = commands.addSourceVerbose([error_media]) src_group = commands.nodeGroup(src) extra_commands.setUIName(src_group, str(it.name or "clip")) # Add otio metadata to this group and the source _add_metadata_to_node(it, src_group) if hasattr(it, "media_reference") and it.media_reference: _add_metadata_to_node(it.media_reference, src) in_frame = out_frame = None if hasattr(it, "media_reference") and it.media_reference: if isinstance(it.media_reference, otio.schema.ImageSequenceReference): in_frame, out_frame = \ it.media_reference.frame_range_for_time_range( range_to_read ) _add_source_bounds(it.media_reference, src, context) if not in_frame and not out_frame: # because OTIO has no global concept of FPS, the rate of the duration # is used as the rate for the range of the source. in_frame = otio.opentime.to_frames(range_to_read.start_time, rate=range_to_read.duration.rate) out_frame = otio.opentime.to_frames(range_to_read.end_time_inclusive(), rate=range_to_read.duration.rate) commands.setIntProperty(src + ".cut.in", [in_frame]) commands.setIntProperty(src + ".cut.out", [out_frame]) commands.setFloatProperty(src + ".group.fps", [float(range_to_read.duration.rate)]) return src_group
def _set_display_to_no_correction(self, event): """ Makes sure we have No Correction set in the View menu by disabling sRGB and Rec709 for all DisplayColor nodes. This is less confusing for users than setting up a display profile, so we do this here. """ display_nodes = commands.nodesOfType("RVDisplayColor") for display_node in display_nodes: commands.setIntProperty("%s.color.sRGB" % display_node, [0], True) commands.setIntProperty("%s.color.Rec709" % display_node, [0], True)
def _create_item(it, track_kind=None): range_to_read = it.trimmed_range() if not range_to_read: raise otio.exceptions.OTIOError( "No valid range on clip: {0}.".format( str(it) ) ) new_media = _create_media_reference(it, track_kind) if not new_media: kind = "smptebars" if isinstance(it, otio.schema.Gap): kind = "blank" new_media = [_create_movieproc(range_to_read, kind)] try: src = commands.addSourceVerbose(new_media) except Exception as e: # Perhaps the media was missing, if so, lets load an error # source print('ERROR: {}'.format(e)) error_media = _create_movieproc(range_to_read, 'smptebars') src = commands.addSourceVerbose([error_media]) src_group = commands.nodeGroup(src) extra_commands.setUIName(src_group, str(it.name or "clip")) # Add otio metadata to this group and the source _add_metadata_to_node(it, src_group) if hasattr(it, "media_reference") and it.media_reference: _add_metadata_to_node(it.media_reference, src) # because OTIO has no global concept of FPS, the rate of the duration is # used as the rate for the range of the source. # RationalTime.value_rescaled_to returns the time value of the object in # time rate of the argument. cut_in = range_to_read.start_time.value_rescaled_to( range_to_read.duration ) commands.setIntProperty(src + ".cut.in", [int(cut_in)]) cut_out = range_to_read.end_time_inclusive().value_rescaled_to( range_to_read.duration ) commands.setIntProperty(src + ".cut.out", [int(cut_out)]) commands.setFloatProperty(src + ".group.fps", [float(range_to_read.duration.rate)]) return src_group
def do_exr_linearization(self, lin_node): """ Makes sure the linearization setting is turned OFF. In order to make sure that happens correctly, we need to set more than just the logtype setting, unfortunately, as header settings can turn it back on otherwise. Setting logtype and sRGB2linear, should be sufficient for all edge cases. :param lin_node: RVLinearize node for the source """ self._logger.info("Set linearize node to 'No Linearization'") commands.setIntProperty("%s.color.logtype" % lin_node, [0], True) commands.setIntProperty("%s.color.sRGB2linear" % lin_node, [0], True)
def toggle_handles(self, var): """ If the handles are "on", lop off 8 at the head and tail, else, add them back in """ source_nodes = commands.closestNodesOfType("RVFileSource") for source_node in source_nodes: source_path = commands.getStringProperty("%s.media.movie" % source_node)[0] start_frame = 0 end_frame = -1 for source in commands.sources(): if source[0] == source_path: start_frame = int(source[1]) end_frame = int(source[2]) break if self._handles_on: commands.setIntProperty("%s.cut.in" % source_node, [start_frame + 9], True) commands.setIntProperty("%s.cut.out" % source_node, [end_frame - 8], True) else: commands.setIntProperty("%s.cut.in" % source_node, [start_frame], True) commands.setIntProperty("%s.cut.out" % source_node, [end_frame], True) # we only want to set the flag and display feedback once, not for each source if self._handles_on: extra_commands.displayFeedback("Handles are OFF", 5.0) self._handles_on = False else: extra_commands.displayFeedback("Handles are ON", 5.0) self._handles_on = True
def toggle_look(self, event): """ If the LookLUT is currently on, turn it off, and vice versa. Display feedback so the user knows what's happening. """ # since the CDL should be enabled or disabled for a single # source rather than on the session as a whole, reference the # currently viewed node to toggle look_node = self._get_node_for_source("RVLookLUT") look_on = commands.getIntProperty("%s.lut.active" % look_node)[0] if look_on: commands.setIntProperty("%s.lut.active" % look_node, [0], True) extra_commands.displayFeedback("Romeo Shot LUT is OFF", 5.0) else: commands.setIntProperty("%s.lut.active" % look_node, [1], True) extra_commands.displayFeedback("Romeo Shot LUT is ON", 5.0)
def do_exr_look_setup(self, look_node, look_path): """ Takes the shot-specific csp (or cube) file that was previously located and applies it. :param look_node: RVLookLUT node :param look_path: string, containing path to look LUT file """ # if the file isn't bundled with the RV package, we can't do anything, so exit if not look_path: self._logger.warning("Look LUT parameter is None!") return if not os.path.exists(look_path): self._logger.warning("Look LUT not found at: %s" % look_path) return commands.readLUT(look_path, look_node) commands.setIntProperty("%s.lut.active" % look_node, [1], True) commands.updateLUT() self._logger.info("Loaded Look LUT: %s" % look_path)
def launch_submit_tool(self): # Flag the session as "sgreview.submitInProgress" so JS submit tool # code can tell this is not Screening Room. # prop = "#Session.sgreview.submitInProgress" try: rvc.newProperty(prop, rvc.IntType, 1) except: pass rvc.setIntProperty(prop, [1], True) rv.runtime.eval( """ { require shotgun_mode; require shotgun_review_app; require shotgun_upload; if (! shotgun_mode.localModeReady()) { // Silence the mode first, then activate it. // shotgun_mode.silent = true; shotgun_mode.createLocalMode(); } if (! shotgun_review_app.localModeReady()) { // Silence the mode first, then activate it. // shotgun_review_app.silent = true; shotgun_review_app.createLocalMode(); } if (! shotgun_upload.localModeReady()) { // Silence the mode first, then activate it. // shotgun_upload.silent = true; shotgun_upload.createLocalMode(); } shotgun_review_app.theMode().internalLaunchSubmitTool(); } """, [])
def toggle_slate(self, var): """ If the slate is "on", lop off the first frame, otherwise, add it back in """ source_nodes = commands.closestNodesOfType("RVFileSource") for source_node in source_nodes: source_path = commands.getStringProperty("%s.media.movie" % source_node)[0] start_frame = 0 for source in commands.sources(): if source[0] == source_path: start_frame = int(source[1]) break if self._slate_on: commands.setIntProperty("%s.cut.in" % source_node, [start_frame + 1], True) else: commands.setIntProperty("%s.cut.in" % source_node, [start_frame], True) # we only want to set the flag and display feedback once, not for each source if self._slate_on: extra_commands.displayFeedback("Slate is OFF", 5.0) self._slate_on = False else: extra_commands.displayFeedback("Slate is ON", 5.0) self._slate_on = True
def _set_lut_3d(proc, nodename, size=32): # FIXME: This clips with >1 scene-linear values, use allocation # vars # Make noop cube size_minus_one = float(size - 1) one_axis = (x / size_minus_one for x in range(size)) cube_raw = itertools.product(one_axis, repeat=3) # Unpack and fix ordering, by turning [(0, 0, 0), (0, 0, 1), ...] # into [0, 0, 0, 1, 0, 0] as generator cube_raw = (item for sublist in cube_raw for item in sublist[::-1]) # Apply transform cube_processed = proc.applyRGB(cube_raw) # Set LUT type and size, then LUT values setStringProperty("%s.lut.type" % nodename, ["RGB"], False) setIntProperty("%s.lut.size" % nodename, [size, size, size], False) setFloatProperty("%s.lut.lut" % nodename, cube_processed, True) # Activate setIntProperty("%s.lut.active" % nodename, [1], False)
def _set_lut_3d(proc, nodename, size = 32): # FIXME: This clips with >1 scene-linear values, use allocation # vars # Make noop cube size_minus_one = float(size-1) one_axis = (x/size_minus_one for x in range(size)) cube_raw = itertools.product(one_axis, repeat=3) # Unpack and fix ordering, by turning [(0, 0, 0), (0, 0, 1), ...] # into [0, 0, 0, 1, 0, 0] as generator cube_raw = (item for sublist in cube_raw for item in sublist[::-1]) # Apply transform cube_processed = proc.applyRGB(cube_raw) # Set LUT type and size, then LUT values setStringProperty("%s.lut.type" % nodename, ["RGB"], False) setIntProperty("%s.lut.size" % nodename, [size, size, size], False) setFloatProperty("%s.lut.lut" % nodename, cube_processed, True) # Activate setIntProperty("%s.lut.active" % nodename, [1], False)
def source_setup_romeo(self, event, noColorChanges=False): """ Finds all the RV nodes we need to operate on, and does the bulk of the color setup dependant on file type. Also handles finding the default file paths for luts and CDLs and storing them in a preferences file so they only have to be picked once. :param event: event passed in from RV :param noColorChanges: """ # event.reject() is done to allow other functions bound to # this event to get a chance to modify the state as well. If # its not rejected, the event will be eaten and no other call # backs will occur. event.reject() args = event.contents().split(";;") group = args[0] action = args[-1] file_source = group_member_of_type(group, "RVFileSource") image_source = group_member_of_type(group, "RVImageSource") source = file_source if image_source == None else image_source lin_pipe_node = group_member_of_type(group, "RVLinearizePipelineGroup") lin_node = group_member_of_type(lin_pipe_node, "RVLinearize") look_pipe_node = group_member_of_type(group, "RVLookPipelineGroup") file_names = commands.getStringProperty("%s.media.movie" % source) # make sure our Display is forced to "No Correction" self._set_display_to_no_correction(event) # Modify the Look Pipeline to account for both EXR and QT handling. We put the # EXR nodes in the QT pipe and vice versa because there are menu items that depend # on the nodes existing that will throw errors if they don't exist. So we just # manage which nodes are active for the particular source types rather than # keeping them out of the pipe. commands.setStringProperty( "%s.pipeline.nodes" % look_pipe_node, ["LinearToAlexaLogC", "RVLookLUT", "LinearToRec709"], True ) alexa_node = group_member_of_type(look_pipe_node, "LinearToAlexaLogC") look_node = group_member_of_type(look_pipe_node, "RVLookLUT") rec709_node = group_member_of_type(look_pipe_node, "LinearToRec709") for file_name in file_names: # if the file is an exr or dpx, handle it accordingly, # anything else we don't need to monkey with aside from # making sure we force it to sRGB to account for # "No Correction" in the display profile if os.path.splitext(file_name)[-1].lower() in [".exr", ".dpx"]: # check prefs to see if there's a saved directory to # look for shot cdls # Use a dictionary instead of a string lcl_file_base = os.path.basename(file_name).split('.')[0] lcl_lut_path = None try: lcl_lut_path = self._look_lut_dict[lcl_file_base] except KeyError: lcl_lut_path = self._retrieve_csp_path(file_name) self._look_lut_dict[lcl_file_base] = lcl_lut_path # now disable our LinearToSRGB node since that's only # in the pipeline for non-EXR files commands.setIntProperty("%s.node.active" % rec709_node, [0], True) self.do_exr_linearization(lin_node) self.do_exr_look_setup(look_node, lcl_lut_path) else: # if we're not dealing with an EXR just make sure we # convert to sRGB to account for the forced display # profile commands.setIntProperty("%s.node.active" % alexa_node, [0], True) commands.setIntProperty("%s.lut.active" % look_node, [0], True) commands.setIntProperty("%s.node.active" % rec709_node, [0], True)