Author Topic: Setting output size for graph outputs created using sbsmutator  (Read 3788 times)

Hello, I've been working on making use of the Substance Automation Toolkit (AKA Substance Batch Tools ???) using batch script (because I have barely used Python) and aside from figuring out what some of the tools such as sbsmutator and sbscooker want in order to work, I managed to generate .sbs and .sbsar files with little issue.

I'm having a small issue though with sbsmutator when using the specialization and --connect-image options and I'm not sure how to handle this since there's nothing pointing this out in the documentation. What's currently happening is that for every image added using the --connect-image command, a Transform 2d node is also added and is downsizing the image to 256x256 which is not desirable.  :-\ The resulting bitmap nodes are using the correct size by default but everything else in the graph does not.

Is there any way to correct this such as removing said nodes, getting the size of the input images and setting the size of the graph, or something like that? Ideally, I want it where input size == output size and not have all of them downsize to 256x256. Once I can do that, we're in business.

This might be totally wrong as I've not used specialization for a while and I'm going from memory, but ...

I think why this happens is because the Transform2D node resolution is set relative to the output size of your graph, and the output size of the graph is set to 256x256 by default. When you use sbsrender to render the outputs of the graph, the graph size is set to the resolution you use in the sbsrender commandline, and then the Transform2D nodes inherit that. So try just ignoring this issue, and use sbsrender.exe with the resolution you want and I think it should do what you want.

And if that doesn't work, you can do this the hard way -> the sbs are only XML format, so you can parse it yourself and find all the image input nodes, then find the Transform2D nodes that are connected to them and directly change them to be the absolute resolution you want directly in the sbs.

Last Edit: September 01, 2017, 07:05:51 pm
Rocksteady Ltd | Senior Technical Artist

I think why this happens is because the Transform2D node resolution is set relative to the output size of your graph, and the output size of the graph is set to 256x256 by default. When you use sbsrender to render the outputs of the graph, the graph size is set to the resolution you use in the sbsrender commandline, and then the Transform2D nodes inherit that. So try just ignoring this issue, and use sbsrender.exe with the resolution you want and I think it should do what you want.

Thanks for the reply. While that should work, the only issue is rendering an image larger or smaller than it actually is. I'm curious if there's a way to get the size of an image and then used that info to set the render size for sbsrender. There's probably a way to get metadata about an image file, either directly or from the image resource in the .sbs package but I'm not sure how to get that.

Edit: I have found that a command-line tool from ImageMagick can fetch this info which might be a solution but it requires installing it just to get something that the Substance package already knows about. Seems silly but that's may be an alternative if the Substance batch tools can't fetch it easily.
Last Edit: September 01, 2017, 08:01:35 pm

Hi,

The "--connect-image" option will automatically add the "Transform 2D" node in order to preserve the dynamic resolution of the substance.
As the "Bitmap" nodes are not dynamic (even in "Relative to Parent", they will be generated in 256x256 outside of SD), we use it in order to adapt the resolution to the graph size.

Even if the bitmap is downscaled to 256x256 in SD, it's not necessary a problem if you set the size (in sbsrender) to a higher resolution as mentioned by Mark (using "--set-value $outputsize@11,11" for example in sbsrender).

One thing you can also do is to use "absolute-size" in order to force the bitmap to be created using an absolute resolution.
Just in case : you can get the different options by doing "sbsmutator.exe --help edit"
Lead technical artist
gaetan.lassagne@allegorithmic.com

Yeah, the original image size remains intact when the Substance package is published and the Bitmap nodes that are generated are set to absolute by default from what I'm seeing. I just wish I can get the image size more easily as a variable and use it to set the output size dynamically per graph.

Right now I'm setting the size manually by checking what the texture size is per texture set and setting the output size that way. While that works, imagine doing that manually for a lot of these and you can see why I want to automate that step as well.  :-\

Unless there's a way to do that using the batch tools, I'll just have to use ImageMagick to get the size and use an if the statement of some variety to set the power of 2 size based on the image size and work with that. Won't be as portable of a batch script with an additional dependency but it'll do for now. Thanks for the assistance and feel free to post a solution if you have one in case others are having the same problem.