def init_state(self): """Queries Soho to initialize the attributes of the class""" state_parms = { "rop": soho.SohoParm("object:name", "string", key="rop"), "soho_outputmode": soho.SohoParm( "soho_outputmode", "integer", skipdefault=False, key="output_mode" ), "soho_diskfile": soho.SohoParm( "soho_diskfile", "string", skipdefault=False, key="disk_file" ), "hip": soho.SohoParm("$HIP", "string", key="hip"), "hipname": soho.SohoParm("$HIPNAME", "string", key="hipname"), "hipfile": soho.SohoParm("$HIPFILE", "string", key="hipfile"), "ver": soho.SohoParm( "state:houdiniversion", "string", ["9.0"], False, key="ver" ), "now": soho.SohoParm("state:time", "real", [0], False, key="now"), "fps": soho.SohoParm("state:fps", "real", [24], False, key="fps"), "pbrt_nanovdb_converter": soho.SohoParm( "pbrt_nanovdb_converter", "string", ["nanovdb_convert -z -f {vdb} {nanovdb}"], False, key="nanovdb_converter", ), } rop = soho.getOutputDriver() parms = soho.evaluate(state_parms, None, rop) for parm in parms: setattr(self, parm, parms[parm].Value[0]) if not self.fps: self.fps = 24.0 self.inv_fps = 1.0 / self.fps return
def init_state(self): """Queries Soho to initialize the attributes of the class""" state_parms = { "rop": soho.SohoParm("object:name", "string", key="rop"), "hip": soho.SohoParm("$HIP", "string", key="hip"), "hipname": soho.SohoParm("$HIPNAME", "string", key="hipname"), "hipfile": soho.SohoParm("$HIPFILE", "string", key="hipfile"), "ver": soho.SohoParm("state:houdiniversion", "string", ["9.0"], False, key="ver"), "now": soho.SohoParm("state:time", "real", [0], False, key="now"), "fps": soho.SohoParm("state:fps", "real", [24], False, key="fps"), } rop = soho.getOutputDriver() parms = soho.evaluate(state_parms, None, rop) for parm in parms: setattr(self, parm, parms[parm].Value[0]) if not self.fps: self.fps = 24.0 self.inv_fps = 1.0 / self.fps return
def init_state(self): """Queries Soho to initialize the attributes of the class""" state_parms = { 'rop': soho.SohoParm('object:name', 'string', key='rop'), 'hip': soho.SohoParm('$HIP', 'string', key='hip'), 'hipname': soho.SohoParm('$HIPNAME', 'string', key='hipname'), 'hipfile': soho.SohoParm('$HIPFILE', 'string', key='hipfile'), 'ver': soho.SohoParm('state:houdiniversion', 'string', ["9.0"], False, key='ver'), 'now': soho.SohoParm('state:time', 'real', [0], False, key='now'), 'fps': soho.SohoParm('state:fps', 'real', [24], False, key='fps'), } rop = soho.getOutputDriver() parms = soho.evaluate(state_parms, None, rop) for parm in parms: setattr(self, parm, parms[parm].Value[0]) if not self.fps: self.fps = 24.0 self.inv_fps = 1.0 / self.fps return
def phantom(obj, now, value): if soho.getOutputDriver().getData('pcrender'): value[:] = [0] return True if obj.evalInt('light_contribprimary', now, value): if value[0]: value[0] = 0 return True return False
def setMattePhantomOverrides(now, matte_objects, phantom_objects): _Settings.MatteOverrides = {} _Settings.PhantomOverrides = {} rop = soho.getOutputDriver() if matte_objects: for obj in rop.objectList('objlist:instance', now, matte_objects): _Settings.MatteOverrides[obj.getName()] = True if phantom_objects: for obj in rop.objectList('objlist:instance', now, phantom_objects): _Settings.PhantomOverrides[obj.getName()] = True
def surface_shader(obj, now, value): if obj.evalShader('shop_surfacepath', now, value): if value[0]: return True plist = obj.evaluate(lshaderParms, now) ltype = plist['light_type'].Value[0] light_texture = plist['light_texture'].Value[0] singlesided = plist['singlesided'].Value[0] reverse = plist['reverse'].Value[0] normalizearea = plist['normalizearea'].Value[0] edgeenable = plist['edgeenable'].Value[0] edgewidth = plist['edgewidth'].Value[0] edgerolloff = plist['edgerolloff'].Value[0] if not isarealighttype(ltype): value[:] = ['opdef:/Shop/v_constant'] return True light_color = get_color(plist) shader = 'opdef:/Shop/v_arealight' # Only output the light color for if it's not a point cloud render if not soho.getOutputDriver().getData('pcrender'): shader += ' lightcolor %g %g %g' % \ ( light_color[0], light_color[1], light_color[2] ) shader += envString(plist) shader += ' normalizearea %d' % normalizearea if light_texture != '': shader += ' texmap "%s"' % light_texture if singlesided: shader += ' singlesided 1 reverse %d' % reverse if edgeenable: shader += ' doedge 1 edgewidth %g edgerolloff %g' % \ (edgewidth, edgerolloff) value[:] = [shader] return True
def outputMPlayFormatOptions(wrangler, cam, now): plist = cam.wrangle(wrangler, _iplay_specific, now) rendermode = plist['rendermode'].Value[0] framemode = plist['framemode'].Value[0] trange = plist['trange'].Value[0] curframe = hou.timeToFrame(now) if trange: frange = cam.wrangleInt(wrangler, 'f', now, [curframe, curframe]) if len(frange) < 2: frange = [curframe, curframe] else: frange = [curframe, curframe] # There are 4 combinations of rendermode and framemode # rendermode/framemode | append | match # ---------------------+------------+----------- # new | new-append | new-frame # current | append | replace # However, we only perform "new" render mode if we the render # frame is at the beginning of the frame range if abs(curframe - frange[0]) < 0.01: rendermode = 'current' if rendermode == 'new': if framemode == 'append': rendermode = 'new-append' else: rendermode = 'new-frame' else: if framemode == 'append': rendermode = 'append' else: rendermode = 'replace' cmd_declare('plane', 'string', 'IPlay.rendermode', [rendermode]) frange = '%d %d' % (int(frange[0]), int(frange[1])) cmd_declare('plane', 'string', 'IPlay.framerange', [frange]) cmd_declare('plane', 'float', 'IPlay.currentframe', [curframe]) rendersource = soho.getDefaultedString('lv_rendersource', [soho.getOutputDriver().getName()]) cmd_declare('plane', 'string', 'IPlay.rendersource', rendersource)
def main(): import sys import hou import soho import sohoglue import SOHOcommon import sys import ctypes if hasattr(sys, 'setdlopenflags'): sys.setdlopenflags(sys.getdlopenflags() | ctypes.RTLD_GLOBAL) import _vfh_ipr from soho import SohoParm LogLevel = type('Enum', (), { 'Msg': 0, 'Info': 1, 'Progress': 2, 'Warning': 3, 'Error': 4, 'Debug': 5 }) def logMessage(level, fmt, *args): _vfh_ipr.logMessage(level, fmt % args) def printDebug(fmt, *args): logMessage(LogLevel.Debug, fmt, *args) def dumpObjects(listName): printDebug("Checking \"%s\"" % listName) for obj in soho.objectList(listName): printDebug(" %s", obj.getName()) def exportObjects(listName): for obj in soho.objectList(listName): _vfh_ipr.exportOpNode(opNode=obj.getName()) def deleteObjects(listName): for obj in soho.objectList(listName): _vfh_ipr.deleteOpNode(opNode=obj.getName()) def getViewParams(camera, sohoCam, t): camParms = { 'space:world': SohoParm('space:world', 'real', [], False), 'focal': SohoParm('focal', 'real', [0.050], False), 'aperture': SohoParm('aperture', 'real', [0.0414214], False), 'orthowidth': SohoParm('orthowidth', 'real', [2], False), 'near': SohoParm('near', 'real', [0.001], False), 'far': SohoParm('far', 'real', [1000], False), 'res': SohoParm('res', 'int', [640, 480], False), 'projection': SohoParm('projection', 'string', ["perspective"], False), 'cropl': SohoParm('cropl', 'real', [-1], False), 'cropr': SohoParm('cropr', 'real', [-1], False), 'cropb': SohoParm('cropb', 'real', [-1], False), 'cropt': SohoParm('cropt', 'real', [-1], False), 'camera': SohoParm('camera', 'string', ['/obj/cam1'], False) } camParmsEval = sohoCam.evaluate(camParms, t) if not camParmsEval: return {} viewParams = {} for key in camParmsEval: viewParams[key] = camParmsEval[key].Value[0] viewParams['transform'] = camParmsEval['space:world'].Value viewParams['ortho'] = 1 if camParmsEval['projection'].Value[0] in { 'ortho' } else 0 viewParams['res'] = camParmsEval['res'].Value cropX = viewParams['res'][0] * viewParams['cropl'] cropY = viewParams['res'][1] * (1.0 - viewParams['cropt']) cropW = viewParams['res'][0] * (viewParams['cropr'] - viewParams['cropl']) cropH = viewParams['res'][1] * (viewParams['cropt'] - viewParams['cropb']) printDebug(" Res: %s" % viewParams['res']) printDebug(" Crop: %i-%i %i x %i " % (cropX, cropY, cropW, cropH)) return viewParams def exportView(rop, camera, sohoCam, t): printDebug("exportView()") _vfh_ipr.exportView(viewParams=getViewParams(camera, sohoCam, t)) mode = soho.getDefaultedString('state:previewmode', ['default'])[0] # Evaluate an intrinsic parameter (see HDK_SOHO_API::evaluate()) # The 'state:time' parameter evaluates the time from the ROP. now = soho.getDefaultedFloat('state:time', [0.0])[0] # Evaluate the 'camera' parameter as a string. # If the 'camera' parameter doesn't exist, use ['/obj/cam1']. # SOHO always returns lists of values. camera = soho.getDefaultedString('camera', ['/obj/cam1'])[0] # MPlay / Render View port. port = soho.getDefaultedInt("vm_image_mplay_socketport", [0])[0] # ROP node. ropPath = soho.getOutputDriver().getName() ropNode = hou.node(ropPath) printDebug("Initialize SOHO...") # Initialize SOHO with the camera. # XXX: This doesn't work for me, but it should according to the documentation... # soho.initialize(now, camera) if not sohoglue.initialize(now, camera, None): soho.error("Unable to initialize rendering module with given camera") # Now, add objects to our scene soho.addObjects(now, "*", "*", "*", True) # Before we can evaluate the scene from SOHO, we need to lock the object lists. soho.lockObjects(now) for sohoCam in soho.objectList('objlist:camera'): break else: soho.error("Unable to find viewing camera for render") sohoOverride = soho.getDefaultedString('soho_overridefile', ['Unknown'])[0] printDebug("Processing Mode: \"%s\"" % mode) if mode in {"generate"}: # generate: Generation phase of IPR rendering # In generate mode, SOHO will keep the pipe (soho_pipecmd) # command open between invocations of the soho_program. # objlist:all # objlist:camera # objlist:light # objlist:instance # objlist:fog # objlist:space # objlist:mat # printDebug("IPR Port: %s" % port) printDebug("Driver: %s" % ropPath) printDebug("Camera: %s" % camera) printDebug("Now: %.3f" % now) _vfh_ipr.init(rop=ropPath, port=port, now=now, viewParams=getViewParams(camera, sohoCam, now)) elif mode in {"update"}: # update: Send updated changes from previous generation # # In this rendering mode, the special object list parameters: # objlist:dirtyinstance # objlist:dirtylight # objlist:dirtyspace # objlist:dirtyfog # will contain the list of all objects modified since the last render # (whether a generate or update). # # As well, the parameters: # objlist:deletedinstance # objlist:deletedlight # objlist:deletedspace # objlist:deletedfog # will list all objects which have been deleted from the scene. # if not _vfh_ipr.isRopValid(): _vfh_ipr.init(rop=ropPath, port=port, now=now, viewParams=getViewParams(camera, sohoCam, now)) else: if _vfh_ipr.setTime(now): # Have to handle "time" event manually here. exportObjects("objlist:dirtyinstance") exportObjects("objlist:dirtylight") # Update view. exportView(ropPath, camera, sohoCam, now)
def header(now, propdefs): global PipeStream, TmpSharedStorage, TmpLocalStorage global ExternalSessionId, ExternalSharedSessionId global SequenceNumber, SequenceLength global InlineGeoDefault LSDhooks.call('pre_header', now) rop = soho.getOutputDriver() plist = rop.evaluate(headerParms, now) hver = plist["hver"].Value[0] cmd_comment("LSD created by Houdini Version: %s" % hver) cmd_comment("Generation Time: %s" % time.strftime("%b %d, %Y at %H:%M:%S")) soho_program = plist.get('soho_program', None) target = LSDsettings.theVersion hip = plist.get('hip', None) hipname = plist.get('hipname', None) ropname = plist.get('ropname', None) tmpsharedstorage = plist.get('tmpsharedstorage', None) tmplocalstorage = plist.get('tmplocalstorage', None) houdinipid = plist['houdinipid'].Value[0] pipepid = plist['pipepid'].Value[0] pipestream = plist.get('pipestream', None) seqnumber = plist.get('seqnumber', None) seqlength = plist.get('seqlength', None) if seqnumber: # The sequence number is the one-based number in the frame sequence # being rendered. SequenceNumber = seqnumber.Value[0] if seqlength: # Number of frames in the sequence being rendered SequenceLength = seqlength.Value[0] if soho_program: cmd_comment(" Soho Script: %s" % fullFilePath(soho_program.Value[0])) if target: cmd_comment(" Render Target: %s" % target) defs = LSDsettings.SettingDefs if len(defs): cmd_comment(" Render Defs: %s" % defs[0]) for i in range(1, len(defs)): cmd_comment(" : %s" % defs[i]) if hip and hipname: cmd_comment(" HIP File: %s/%s, $T=%g, $FPS=%g" % (hip.Value[0], hipname.Value[0], now, FPS)) if ropname: cmd_comment(" Output driver: %s" % ropname.Value[0]) cmd_version(hver) if propdefs: # Output property defaults before we output any other settings cmd_defaults(propdefs) # Renderer frame graph configuation cmd_config("$LAVA_HOME/conf/default.py") cmd_comment(None) cmd_declare('global', 'float', 'global:fps', [FPS]) # TODO: do we really need this !? #cmd_hscript('fps %g; tcur %g' % (FPS, now)) verbose = plist.get('lv_verbose', None) if verbose: cmd_property('renderer', 'verbose', verbose.Value) cmd_comment(None) if not pipestream: cmd_comment('Unable to determine whether writing to a pipe') PipeStream = True else: PipeStream = (pipestream.Value[0] != 0) if hip: hipvar = hip.Value[0] else: hipvar = "" hipvar = rop.getDefaultedString('lv_hippath', now, [hipvar])[0] # Setting the HIP variable in a conditional so users can override # the HIP variable in the .ifd file. cmd_setenv('HIP', '$HIP_OVERRIDE') cmd_if('"$HIP" == ""') cmd_setenv('HIP', hipvar) cmd_endif() def isValidTempDir(path): # Make sure we can either create the sub-directories of the path, or # that the path itself is writeable. if os.path.isdir(path): return os.access(path, os.W_OK) head, tail = os.path.split(path) return isValidTempDir(head) if head else False if not tmpsharedstorage: # We still need to create a storage path, so put it in the HIP # directory. This is where assets will be saved for the LSD. tmpsharedstorage = hou.expandString("$HIP/ifds/storage") else: tmpsharedstorage = tmpsharedstorage.Value[0] if not isValidTempDir(tmpsharedstorage): soho.warning( "Path specified by lv_tmpsharedstorage is read-only. %s" % ("this may cause issues with non-inline geometry")) tmpsharedstorage = hou.expandString("$HOUDINI_TEMP_DIR/ifds/storage") if not tmplocalstorage: # We still need to create a storage path, so put it in the # HOUDINI_TEMP_DIR directory. This is where assets will be saved for # the LSD. tmplocalstorage = hou.expandString("$HOUDINI_TEMP_DIR/ifds/storage") else: tmplocalstorage = tmplocalstorage.Value[0] # Set the external storage variable set into a conditional so if the # variable is set before mantra is run, that value will be used instead. cmd_if('"$_TMP_SHARED_STORAGE" == ""') cmd_setenv('_TMP_SHARED_STORAGE', tmpsharedstorage) cmd_endif() cmd_if('"$_TMP_LOCAL_STORAGE" == ""') cmd_setenv('_TMP_LOCAL_STORAGE', tmplocalstorage) cmd_endif() TmpSharedStorage = tmpsharedstorage # Stash for later TmpLocalStorage = tmplocalstorage # Stash for later frame = now * FPS + 1 frame_frac = int((frame % 1) * 100) if PipeStream: ExternalSessionId = '%d_%s.%d_%03d' % (pipepid, hipname.Value[0], int(frame), frame_frac) ExternalSharedSessionId = '%d_%s_shared' % (houdinipid, hipname.Value[0]) else: ExternalSessionId = '%s.%d_%03d' % (hipname.Value[0], int(frame), frame_frac) ExternalSharedSessionId = '%s_shared' % (hipname.Value[0]) if os.getenv('MANTRA_DEBUG_INLINE_STORAGE'): # Normally, we want to rely on the lv_inlinestorage parameter (which # defaults to False). For convenience we can set this variable to # override the setting. Note that this may impact performance since # Houdini and mantra are able to multi-thread saving/loading # geometry. This should be used for debugging only. InlineGeoDefault = [1] LSDhooks.call('post_header', now)
def render(): """Evaluate and package the HDA parameters and submit a job to HQueue.""" # Build a dictionary of base parameters and add the HQueue Render-specific # ones. parms = hqrop.getBaseParameters() use_cloud = (hou.ch("hq_use_cloud1") if hou.parm("hq_use_cloud1") is not None else 0) num_cloud_machines = (hou.ch("hq_num_cloud_machines") if hou.parm("hq_num_cloud_machines") is not None else 0) machine_type = (hou.ch("hq_cloud_machine_type") if hou.parm("hq_cloud_machine_type") is not None else "") use_output_driver = bool(use_cloud) or parms["hip_action"] != "use_ifd" # validate the machine type if machine_type not in ['c1.medium', 'c1.xlarge', 'm1.small', 'm1.large', 'm1.xlarge']: machine_type = 'c1.xlarge' parms.update({ "assign_ifdgen_to" : hou.parm("hq_assign_ifdgen_to").evalAsString(), "ifdgen_clients": hou.ch("hq_ifdgen_clients").strip(), "ifdgen_client_groups" : hou.ch("hq_ifdgen_client_groups").strip(), "batch_all_frames": hou.ch("hq_batch_all_frames"), "frames_per_job": hou.ch("hq_framesperjob"), "render_frame_order": hou.parm("hq_render_frame_order").evalAsString(), "make_ifds": hou.ch("hq_makeifds"), "max_hosts_per_job": hou.ch("hq_max_hosts"), "min_hosts_per_job": hou.ch("hq_min_hosts"), "is_CPU_number_set": bool(hou.ch("hq_is_CPU_number_set")), "CPUs_to_use": hou.ch("hq_CPUs_to_use"), "output_ifd": hou.parm("hq_outputifd").unexpandedString().strip(), "use_output_driver" : use_output_driver, "use_cloud": use_cloud, "num_cloud_machines": num_cloud_machines, "cloud_machine_type" : machine_type, "use_render_tracker" : hou.ch("hq_use_render_tracker"), "delete_ifds": hou.ch("hq_delete_ifds"), "render_single_tile": bool(hou.ch("hq_render_single_tile")), }) if use_output_driver: # Convert output_driver path to an absolute path. parms["output_driver"] = hou.ch("hq_driver").strip() rop_node = hou.pwd().node(parms["output_driver"]) if rop_node: parms["output_driver"] = rop_node.path() parms["ifd_path"] = hou.parm("hq_outputifd").unexpandedString().strip() output_driver = hqrop.getOutputDriver(hou.pwd()) # Turn "off" Mantra-specific parameters if there is an output driver # and it is not a Mantra ROP. if output_driver and output_driver.type().name() != "ifd": parms["make_ifds"] = False parms["min_hosts_per_job"] = 1 parms["max_hosts_per_job"] = 1 else: parms.update({ "ifd_path" : hou.parm("hq_input_ifd").unexpandedString().strip(), "start_frame" : hou.ch("hq_frame_range_1"), "end_frame" : hou.ch("hq_frame_range_2"), "frame_skip" : hou.ch("hq_frame_range_3"), # If we are not using an output driver we are using IFDs and so # we won't be making them "make_ifds" : False, }) if parms["frame_skip"] <= 0: parms["frame_skip"] = 1 # We stop if we cannot establish a connection with the server if (not parms["use_cloud"] and not hqrop.doesHQServerExists(parms["hq_server"])): return None if "ifd_path" in parms and not parms["use_cloud"]: expand_frame_variables = False parms["ifd_path"] = hqrop.substituteWithHQROOT( parms["hq_server"], parms["ifd_path"], expand_frame_variables) # Validate parameter values. if (not hqrop.checkBaseParameters(parms) or not _checkRenderParameters(parms)): return if use_output_driver and parms["hip_action"] == "use_current_hip": if not hqrop.checkOutputDriver(parms["output_driver"]): return if hqrop.checkForRecursiveChain(hou.pwd()): hqrop.displayError(("Cannot submit HQueue job because" " %s is in the input chain of %s.") % (hou.pwd().path(), parms["output_driver"])) return # If we're not supposed to run this job on the cloud, submit the job. # Otherwise, we'll display the file dependency dialog. if parms["use_cloud"]: # We don't want to keep the interrupt dialog open, so we exit this soho # script so the dialog closes and schedule an event to run the code to # display the dialog. import soho rop_node = hou.node(soho.getOutputDriver().getName()) cloud.selectProjectParmsForCloudRender( rop_node, parms["num_cloud_machines"], parms["cloud_machine_type"]) return # Automatically save changes to the .hip file, # or at least warn the user about unsaved changes. should_continue = hqrop.warnOrAutoSaveHipFile(parms) if not should_continue: return hqrop.submitJob(parms, _byu_troubleshoot_hq)
parm = {'diskfile': SohoParm('soho_diskfile', 'string', ['*'], False)} parmlist = soho.evaluate(parm) filename = parmlist['soho_diskfile'].Value[0] # We can't emit file to stdout, because appleseed.cli currently doesn't accept stdit # with open(filename, 'w') as file: # technically preambule is not part of project object: date = datetime.strftime(datetime.today(), "%b %d, %Y at %H:%M:%S") stat = '<!-- Generation time: %g seconds -->' % (time.time() - clockstart) preambule = APSsettings.PREAMBULE.format( houdini_version=hou.applicationVersionString(), aps_version=APSsettings.__version__, date=date, renderer_version=APSsettings.__appleseed_version__, driver=soho.getOutputDriver().getName(), hipfile=hou.hipFile.name(), TIME=now, FPS=FPS, ) if mode == "update": xform = [] cam.evalFloat("space:world", now, xform) xform = hou.Matrix4(xform).transposed().asTuple() xform = " ".join(map(str, xform)) print xform else: # first line if stdin is (socket, mode) where 0=default, 1=ipr # I would love to have custom tag in appleseed. if mode != 'default':
mode = soho.getDefaultedString('state:previewmode', ['default'])[0] # Evaluate an intrinsic parameter (see HDK_SOHO_API::evaluate()) # The 'state:time' parameter evaluates the time from the ROP. now = soho.getDefaultedFloat('state:time', [0.0])[0] # Evaluate the 'camera' parameter as a string. # If the 'camera' parameter doesn't exist, use ['/obj/cam1']. # SOHO always returns lists of values. camera = soho.getDefaultedString('camera', ['/obj/cam1'])[0] # MPlay / Render View port. port = soho.getDefaultedInt("vm_image_mplay_socketport", [0])[0] # ROP node. ropPath = soho.getOutputDriver().getName() ropNode = hou.node(ropPath) # Use callbacks or SOHO render_rt_update_mode = hou.evalParm("render_rt_update_mode") printDebug("Initialize SOHO...") # Initialize SOHO with the camera. # XXX: This doesn't work for me, but it should according to the documentation... # soho.initialize(now, camera) if not sohoglue.initialize(now, camera, None): soho.error("Unable to initialize rendering module with given camera") # Now, add objects to our scene soho.addObjects(now, "*", "*", "*", True)
def isphoton(): return soho.getOutputDriver().getData("photonrender")
def render(): """Evaluate and package the HDA parameters and submit a job to HQueue.""" # Build a dictionary of base parameters and add the HQueue Render-specific # ones. parms = hqrop.getBaseParameters() use_cloud = (hou.ch("hq_use_cloud1") if hou.parm("hq_use_cloud1") is not None else 0) num_cloud_machines = (hou.ch("hq_num_cloud_machines") if hou.parm("hq_num_cloud_machines") is not None else 0) machine_type = (hou.ch("hq_cloud_machine_type") if hou.parm("hq_cloud_machine_type") is not None else "") use_output_driver = bool(use_cloud) or parms["hip_action"] != "use_ifd" # validate the machine type if machine_type not in [ 'c1.medium', 'c1.xlarge', 'm1.small', 'm1.large', 'm1.xlarge' ]: machine_type = 'c1.xlarge' parms.update({ "assign_ifdgen_to": hou.parm("hq_assign_ifdgen_to").evalAsString(), "ifdgen_clients": hou.ch("hq_ifdgen_clients").strip(), "ifdgen_client_groups": hou.ch("hq_ifdgen_client_groups").strip(), "batch_all_frames": hou.ch("hq_batch_all_frames"), "frames_per_job": hou.ch("hq_framesperjob"), "render_frame_order": hou.parm("hq_render_frame_order").evalAsString(), "make_ifds": hou.ch("hq_makeifds"), "max_hosts_per_job": hou.ch("hq_max_hosts"), "min_hosts_per_job": hou.ch("hq_min_hosts"), "is_CPU_number_set": bool(hou.ch("hq_is_CPU_number_set")), "CPUs_to_use": hou.ch("hq_CPUs_to_use"), "output_ifd": hou.parm("hq_outputifd").unexpandedString().strip(), "use_output_driver": use_output_driver, "use_cloud": use_cloud, "num_cloud_machines": num_cloud_machines, "cloud_machine_type": machine_type, "use_render_tracker": hou.ch("hq_use_render_tracker"), "delete_ifds": hou.ch("hq_delete_ifds"), "render_single_tile": bool(hou.ch("hq_render_single_tile")), }) if use_output_driver: # Convert output_driver path to an absolute path. parms["output_driver"] = hou.ch("hq_driver").strip() rop_node = hou.pwd().node(parms["output_driver"]) if rop_node: parms["output_driver"] = rop_node.path() parms["ifd_path"] = hou.parm("hq_outputifd").unexpandedString().strip() output_driver = hqrop.getOutputDriver(hou.pwd()) # Turn "off" Mantra-specific parameters if there is an output driver # and it is not a Mantra ROP. if output_driver and output_driver.type().name() != "ifd": parms["make_ifds"] = False parms["min_hosts_per_job"] = 1 parms["max_hosts_per_job"] = 1 else: parms.update({ "ifd_path": hou.parm("hq_input_ifd").unexpandedString().strip(), "start_frame": hou.ch("hq_frame_range_1"), "end_frame": hou.ch("hq_frame_range_2"), "frame_skip": hou.ch("hq_frame_range_3"), # If we are not using an output driver we are using IFDs and so # we won't be making them "make_ifds": False, }) if parms["frame_skip"] <= 0: parms["frame_skip"] = 1 # We stop if we cannot establish a connection with the server if (not parms["use_cloud"] and not hqrop.doesHQServerExists(parms["hq_server"])): return None if "ifd_path" in parms and not parms["use_cloud"]: expand_frame_variables = False parms["ifd_path"] = hqrop.substituteWithHQROOT(parms["hq_server"], parms["ifd_path"], expand_frame_variables) # Validate parameter values. if (not hqrop.checkBaseParameters(parms) or not _checkRenderParameters(parms)): return if use_output_driver and parms["hip_action"] == "use_current_hip": if not hqrop.checkOutputDriver(parms["output_driver"]): return if hqrop.checkForRecursiveChain(hou.pwd()): hqrop.displayError(("Cannot submit HQueue job because" " %s is in the input chain of %s.") % (hou.pwd().path(), parms["output_driver"])) return # If we're not supposed to run this job on the cloud, submit the job. # Otherwise, we'll display the file dependency dialog. if parms["use_cloud"]: # We don't want to keep the interrupt dialog open, so we exit this soho # script so the dialog closes and schedule an event to run the code to # display the dialog. import soho rop_node = hou.node(soho.getOutputDriver().getName()) cloud.selectProjectParmsForCloudRender(rop_node, parms["num_cloud_machines"], parms["cloud_machine_type"]) return # Automatically save changes to the .hip file, # or at least warn the user about unsaved changes. should_continue = hqrop.warnOrAutoSaveHipFile(parms) if not should_continue: return hqrop.submitJob(parms, _byu_troubleshoot_hq)
cmd_loadotl(otls) # # Output OTL preferences set in Houdini otprefs = soho.getDefaultedString('state:otprefer', []) if soho.getDefaultedInt('lv_otlfullpath', [0])[0]: for i in range(1, len(otprefs), 2): otprefs[i] = hou.expandString(otprefs[i]) if len(otprefs): cmd_comment("OTL preferences from the .hip file") cmd_otprefer(otprefs) if inheritedproperties: # Output object level properties which are defined on the output driver cmd_comment('Object properties defined on output driver') LSDsettings.outputObject(soho.getOutputDriver(), now) isphoton = parmlist['engine'].Value[0] == 'photon' or \ parmlist['engine'].Value[0] == 'viewphoton' # # If there's only one camera, output it here donecamera = False do_main = parmlist['main'].Value[0] if do_main and mode == "generate" and len(camera_list) == 1: sub_camera = camera_list[0] if sub_camera: if not LSDhooks.call('pre_mainimage', parmlist, objparms, now, sub_camera): cmd_comment('Main image from %s' % sub_camera.getName()) LSDframe.renderCamera(sub_camera, now, forphoton=isphoton)
geo_parm='phantom_objects', light_parm='', fog_parm='') soho.removeObjects(now, excludeobject, excludelights, excludefog, geo_parm='excludeobject', light_parm='excludelights', fog_parm='excludefog') # Lock off the objects we've selected soho.lockObjects(now) IFDsettings.clearLists() IFDsettings.load(now) IFDgeo.reset() if inheritedproperties: # Output object level properties which are defined on the output driver ray_comment('Object properties defined on output driver') IFDsettings.outputObject(soho.getOutputDriver(), now) if decl_shops: IFDgeo.declareAllMaterials(now, decl_shops > 1) # # Output objects # IFDframe.outputObjects(now, soho.objectList('objlist:instance'), soho.objectList('objlist:light'), soho.objectList('objlist:space'), soho.objectList('objlist:fog'), -1, -1)