Example #1
0
def get_settings_commandline(node: hou.Node):
    result = []

    if node.evalParm("settings_format"):
        result += [
            "--output-format",
            node.parm("output_format").evalAsString()
        ]

    if node.evalParm("settings_compression"):
        result += [
            "--png-format-compression",
            node.parm("png_compression").evalAsString()
        ]

    if node.evalParm("settings_colorspace"):
        result += [
            "--output-colorspace",
            node.parm("color_space").evalAsString()
        ]

    if node.evalParm("settings_cachedir"):
        result += ["--cache-dir", node.parm("cache_dir").evalAsString()]

    if node.evalParm("settings_cpucount"):
        result += ["--cpu-count", str(node.parm("cpu_count").eval())]

    if node.evalParm("settings_memorybudget"):
        result += ["--memory-budget", str(node.parm("memory_budget").eval())]

    if node.evalParm("settings_ocioconfig"):
        result += ["--ocio", node.parm("ocio_config").evalAsString()]

    if node.evalParm("use_ace"):
        result += ["--ace"]
        result += [
            "--ace-render-intent",
            node.parm("ace_render_intent").evalAsString()
        ]
        result += [
            "--ace-working-space",
            node.parm("ace_working_space").evalAsString()
        ]

        icc_path = node.evalParm("icc_profiles_path")
        if icc_path.strip():
            result += ["--icc-profiles-dir", icc_path]

    return result
Example #2
0
def get_time_commandline(node: hou.Node):
    time_type = node.parm("time_type").evalAsString()

    time = 0.0
    (frame_start, frame_end, _) = node.parmTuple("f").eval()
    frame = hou.frame()

    if time_type == "range":
        time = (frame - frame_start) / (frame_end - frame_start)
    elif time_type == "range_loop":
        time = (frame - frame_start) / (frame_end - frame_start + 1.0)
    elif time_type == "custom":
        time = node.evalParm("time")

    return ["--set-value", f"$time@{time}"]
Example #3
0
def run_sbsrender(node: hou.Node):
    sbsar_json = load_sbsar_json(node)

    cl = [node.evalParm("sbsrender_path")]
    cl += ["render"]
    cl += [node.parm("sbsar").evalAsString()]

    output_path: str = node.evalParm("output_path")
    if output_path.strip():
        cl += ["--output-path", output_path]

    output_name: str = node.evalParm("output_name")
    if output_name.strip():
        cl += ["--output-name", output_name]

    if node.evalParm("engine_override"):
        cl += ["--engine", node.parm("engine").evalAsString()]

    cl += get_settings_commandline(node)

    pattern = node.parm("output_graphs").evalAsString()
    pattern = pattern.strip()
    if pattern and pattern != "*":
        cl += get_output_graphs_commandline(node, sbsar_json)

    cl += get_time_commandline(node)

    cl += get_inputs_commandline(node)
    if node.evalParm("use_graph_outputs"):
        cl += get_outputs_commandline(node)

    size_type = node.evalParm("size_type")
    size_x = node.parm("size_x").evalAsString()
    size_y = node.parm("size_y").evalAsString()

    if size_type == 0:
        cl += ["--set-value", f"$outputsize@{size_x},{size_x}"]
    else:
        cl += ["--set-value", f"$outputsize@{size_x},{size_y}"]

    if node.evalParm("use_randomseed"):
        cl += ["--set-value", f"$randomseed@{node.evalParm('random_seed')}"]

    cl += get_parms_commandline(node)

    if node.parm("use_preset").eval():
        cl += ["--use-preset", node.parm("preset").evalAsString()]

    #print(cl)

#    with hou.InterruptableOperation(f"Rendering SBSAR: {node.parm('sbsar').evalAsString()}", open_interrupt_dialog=True):

    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    result = subprocess.run(cl,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            startupinfo=startupinfo)

    if (result.returncode != 0):
        message = result.stderr.decode("utf-8")
        _error(message, hou.NodeError)
    elif node.evalParm("pdg_logoutput"):
        result_json = result.stdout.decode("utf-8")
        result = json.loads(result_json)

        for graph in result:
            if "outputs" not in graph:
                continue

            for output in graph["outputs"]:
                if "value" not in output:
                    continue

                print(f"OUTPUT_FILE:{output['value']};")
Example #4
0
def refresh_sbsar_cache(node: hou.Node):
    sbsar_path = node.parm("sbsar").evalAsString()
    sbsar_info = get_sbsar_info(node.evalParm("sbsrender_path"), sbsar_path)
    sbsar_json = get_sbsar_json(sbsar_info)
    cache_sbsar_json(node, sbsar_json)