Author Topic: sbsrender absoloute output size issue  (Read 153 times)

Hey guys,

I am on linux try to use sbsrender to output texture maps from bunch of .sbsar files.

The shell command line I am using is:

Code: [Select]
sbsrender render --output-path '{inputPath}' --set-value '$outputsize@4,4' --output-format 'tif' --inputs /file/location/xxx.sbsar
But when I use this same command line for different .sbsar files, I ended up with different map resolution. Some .sbsar file gave me 512x512 maps while others give me 2048x2048.

I know this might be because the original .sbs files use different base resolutions. Just wondering, can anybody show me a correct way to export maps in a desired resolution? for example, if I want 4K maps, it will give me maps in that certain resolution. I dont mind using sbsmutator to the change some base settings, just need to know how to do it in batch/script since I have tons of sbs archive files to work on.

Many thanks!
Oscar


Code: [Select]
sbsrender render --output-path '{inputPath}' --set-value '$outputsize@4,4' --output-format 'tif' --inputs /file/location/xxx.sbsar
What you have there with --setvalue '$outputsize@4, 4' is the correct way of doing it (except 4k would be --setvalue '$outputsize@12, 12').

As you suspected, the issue is the resolution defined in the materials, so you'll have to fix them.
This might help: https://docs.substance3d.com/sat/setup-and-getting-started/frequently-asked-questions

Hi Nev TD,

Thank you for your reply!

I actually checked that page before. But I don't think that solved my question. The current way I am exporting textures is still a relative resolution. If I use same code for different .sbsar files it might give different resolution.

I just wanna know how to use automation toolkit to change all of .sbs files base resolutions to a curtain value, so when use the sbsrender command I can get a fixed resolution value (4K, 8K, etc...). Can you give an example, or is there an ideal way to do it?

Thank you very much for the reply again!
Oscar

I couldn't find a way to do this in sbsmutator; however, I was able to use pysbs to set the default parent inheritance value for outputsize, however, I can't find a way to switch the inheritance mode from absolute to parent.

I'm using a much older version of SAT, so it's possible it's a bug that's been resolved since.
Try it on your end and see if you can get any further with the script.

Note: This will overwrite the sbs file being processed, so use at your own risk. Preferably with an isolated test material.
Code: [Select]
from pysbs import context, substance, sbsenum

sbs_mtls = [] # Your list of sbs files to process.

def set_sbs_graph_to_relative(sbs_path):
    # Build doc.
    ctx = context.Context()
    sbs_doc = substance.SBSDocument(ctx, sbs_path)
    sbs_doc.parseDoc()
   
    # Get your graph.
    graph = sbs_doc.getSBSGraphList()[0]
   
    # Change the outputsize inheritance value.
    # Bug: The aRelativeTo argument doesn't appear to do anything.
    #
    # https://docs.substance3d.com/sat/pysbs-python-api/api-content/libraries/sbsenum
    graph.setBaseParameterValue(
        aParameter=sbsenum.CompNodeParamEnum.OUTPUT_SIZE,
        aParamValue=[sbsenum.OutputSizeEnum.SIZE_1, sbsenum.OutputSizeEnum.SIZE_1],
        aRelativeTo=sbsenum.ParamInheritanceEnum.PARENT
    )
   
    # Save pkg.
    sbs_doc.writeDoc()
   
for pkg in sbs_mtls:
    set_sbs_graph_to_relative(pkg)
   

Nevermind, I digged a bit into the source code; here's a hackey workaround to force the inheritance mode.
Try the script in my previous post first. If it doesn't change the outputsize inheritance mode, try the script below.

Note: As I mentioned before, this will overwrite the sbs file being processed; try it out with a test material and add your own backup mechanisms.
Code: [Select]
from pysbs import context, substance, sbsenum

sbs_mtls = [] # Your list of sbs files to process.

def set_sbs_graph_to_relative(sbs_path):
    # Build doc.
    ctx = context.Context()
    sbs_doc = substance.SBSDocument(ctx, sbs_path)
    sbs_doc.parseDoc()
   
    # Get your graph.
    graph = sbs_doc.getSBSGraphList()[0]
   
    # Change the outputsize inheritance value.
    # Bug: The aRelativeTo argument doesn't appear to do anything.
    #
    # https://docs.substance3d.com/sat/pysbs-python-api/api-content/libraries/sbsenum
    graph.setBaseParameterValue(
        aParameter=sbsenum.CompNodeParamEnum.OUTPUT_SIZE,
        aParamValue=[sbsenum.OutputSizeEnum.SIZE_1, sbsenum.OutputSizeEnum.SIZE_1],
        aRelativeTo=sbsenum.ParamInheritanceEnum.PARENT
    )
   
    # Hackey inheritance override.
    for param in graph.mBaseParameters:
        if param.mName == 'outputsize':
            param.mRelativeTo = str(sbsenum.ParamInheritanceEnum.PARENT)

    # Save pkg.
    sbs_doc.writeDoc()
   
for pkg in sbs_mtls:
    set_sbs_graph_to_relative(pkg)
   

And just in case I misunderstood your requirements; if you're asking to force the resolution in the material directly rather than using the sbsrender --set-value flag.

Just replace:
Code: [Select]
    graph.setBaseParameterValue(
        aParameter=sbsenum.CompNodeParamEnum.OUTPUT_SIZE,
        aParamValue=[sbsenum.OutputSizeEnum.SIZE_1, sbsenum.OutputSizeEnum.SIZE_1],
        aRelativeTo=sbsenum.ParamInheritanceEnum.PARENT
    )

    # Hackey inheritance override.
    for param in graph.mBaseParameters:
        if param.mName == 'outputsize':
            param.mRelativeTo = str(sbsenum.ParamInheritanceEnum.PARENT)


With:
Code: [Select]
    graph.setBaseParameterValue(
        aParameter=sbsenum.CompNodeParamEnum.OUTPUT_SIZE,
        aParamValue=[sbsenum.OutputSizeEnum.SIZE_4096 , sbsenum.OutputSizeEnum.SIZE_4096],
        aRelativeTo=sbsenum.ParamInheritanceEnum.ABSOLUTE
    )

    # Hackey inheritance override.
    for param in graph.mBaseParameters:
        if param.mName == 'outputsize':
            param.mRelativeTo = str(sbsenum.ParamInheritanceEnum.ABSOLUTE)

The latter should ignore the --set-value '$outputsize...' flag and use the base parameter outputsize value instead.
Last Edit: December 04, 2019, 08:13:44 pm

wow thank you so much for the detailed reply!

I have used pysbs yet. But I will definitely give it a go with ur code. This should be exactly what I need. I will test them and let you guys know how it goes.

Thank you so much for the reply again Nev TD!