Author Topic: SBSRender Output Name Token Support  (Read 3028 times)

Is there a full list of supported output name tokens for SBSRender?
Designer supports more output attribute tokens for example:
Code: [Select]
$(graph)_$(label)
While SBSRender seems to take only the
Code: [Select]
OutputNodeName

According to the docs it takes the following 3:
Code: [Select]
--output-name <name> [default: "{inputName}_{inputGraphUrl}_{outputNodeName}"]
    Output file name. Default='{inputName}_{inputGraphUrl}_{outputNodeName}'.
    You can use the following patterns that will be replaced by the program when saving the result of the process:
    - {inputName} replaced by the archive filename. - {inputGraphUrl} replaced by the graph url. - {outputNodeName} replaced by the output name.
https://docs.substance3d.com/sat/command-line-tools/sbsrender/sbsrender-command-line-options

Thanks NevTD. I was afraid that those were the only available options, but was hoping to be surprised with more :)

This seems to not reflect and support what user's are use to outputting in Designer.
For now, I'll have to catch and rename those output files in code, but that doesn't seem ideal

For now, I'll have to catch and rename those output files in code, but that doesn't seem ideal

Sigh...I hear you. I went through this myself recently and had to re-write the way my SAT wrapper for the command line tools worked.

Bear in mind that you will not be able to "resolve" the aliases or retrieve the resolved output path to the file via sbsrender.
So, if you're planning on running certain texture channels through any kind of post-processing (e.g. oiiotool), it will become extremely difficult since you won't have the resolved path to the texture.
Reference: https://forum.substance3d.com/index.php/topic,29501.0.html

I ended up working around this by querying all necessary information from the material (via pysbs) and resolving the export name myself and feeding that into --output-name argument, rather than using the aliases.

You can even set up a mapping layer using your own custom aliases that resolve and return a file name from relevant data in the material via pysbs (e.g. graph id, output id, output label, user data etc.). This is far more suitable for a pipeline and a very flexible solution (if you need it).

Really rough example:
Code: [Select]
def resolve_output_name(aliases, channel):
    if '$output_label' in aliases:
        out_label = # Run pysbs operation to query output node's label for a specific channel.
    if '$graph_name' in aliases:
        graph_name = # Run pysbs operation to query master graph name.
   
    return '{graph}_{output}'.format(graph=graph_name, output=out_label)
Last Edit: September 26, 2019, 06:34:53 pm

Regarding..
Quote
retrieve the resolved output path to the file via sbsrender.
SBSRender does actually output a useful dictionary of information on each graph's rendered output files, including the output identifier and absolute path of the rendered image. I parse that out of StdOut after a successful render process and convert that to a dictionary as necessary for post processing or daisy-chaining into another substance.

I also do path resolving prior to execution, where I can pre-compute "anticipated" output names from a configured SBSrender wrapper object. That is useful as you said.. where you can validate naming tokens on the fly, and display a mapped output name to a user in some UI.

SBSRender does actually output a useful dictionary of information on each graph's rendered output files, including the output identifier and absolute path of the rendered image.

Really? I've never come across this.
Is this the default behavior you're seeing or are you using a specific argument with sbsrender to retrieve this dict?

We're using an older version and I definitely haven't captured this dict from stdout as default behavior, maybe they've changed it recently.
Last Edit: September 26, 2019, 08:33:23 pm