This repository contains a few samples for using the Substance Automation Toolkit and providing a framework of examples for introducing automation in a content development pipeline.
The provided examples are split into two categories:
- using the Command Line Tools
- using the Python API.
Note: This repository demonstrates only the following concepts: (code can be easily modified to achieve most other available options)
- Headless Bent-Normal Map texture baking from a list of [low_poly, high poly] pairs, with outputting the results in a predefined location
To use the sample code with the Command Line Tools, first:
In the text file, each row is a pairing of low and high poly paths separated by a space, as seen below.
<path_to_low_poly> <path_to_high _poly>
For example:
C:\substance_test\lows\my_asset_low.fbx C:\substance_test\highs\my_asset_high.fbx
Modify the file to list your matchings.
5) Line 18 can be modified to point to a different install path if your Substance installation is not default.
18: cd "C:\Program Files\Allegorithmic\Substance Automation Toolkit" >nul
25: --output-path "C:\bakes\output_folder" ^
26: --output-name "{inputName}_BN" ^
8) Other parameters in between lines 23 and 33 can be modified (or added) to change the properties of the bake process.
Examples currently unavailable, but can be kickstarted using the Windows 10 examples and the Substance Automation Toolkit documentation.
The samples setup with Pysbs Python API in this repository are using Python 2.7 (more specifically 2.7.18). The Pysbs Python API requires a bit more setup, but is more extensive and configurable than the Command Line Tools.
Although the complete installation documentation is available on the SAT Getting Started page, I've detailed the important steps below.
As mentioned in the Substance by Adobe documentation, the Pysbs API is compatible with Python 2.7 and Python 3.5. These samples use Python 2.7, which for Windows 10 can be downloaded from here.
Pip can be obtained using these instructions.
First, you must obtain the "Pysbs" archive. This archieve is either under the Licence tab on your account on the Substance Account website or in your default Substance install location under the "Pyton Api" directory in the Substance Automation Toolkit directory.
After you have the .zip archive, you'll need to use the Command Line to install the API. As exemplified in the Substance documentation, use the following command:
pip install Pysbs-x.y.z.zip --find-links <apiDir>
Below is a better example of what the install command looks like for the default installation of the 2018.2.0 version.
pip install "C:\Program Files\Allegorithmic\Substance Automation Toolkit\Python API\Pysbs-2018.2.0.zip"
First, the user should customize two files: user_settings.json and config_bentnormal.json.
{
"substance_automation_toolkit_path": "C:\\Program Files\\Allegorithmic\\Substance Automation Toolkit",
"output_path": "C:\\substance_test\\output_folder\\",
"lows_path": "C:\\substance_test\\lows",
"highs_path": "C:\\substance_test\\highs",
"input_format": "fbx",
"output_format": "tga",
"low_poly_nameflag": "_low",
"high_poly_nameflag": "_high"
}
{
"output_name_flag": "_BentNormal",
"output_size": 12,
"antialiasing": 0,
"ignore_backface": true,
"self_occlusion": 0,
"use_lowdef_as_highdef": false,
"uv_set": 0
}
The code will go the following operations, in order:
- check if the output path exists and if it doesn't, create the directories
- read the low poly folder and assemble a list of the files that are meshes of the provided type
- read the high poly folder and for each found low poly mesh, determine what the high poly mesh name should be
- if there is a high poly mesh that matches the name conditions of the low poly, create a dictionary of matches (for example: "mesh_low" matches "mesh_high", but "mesh" matches "mesh" if the names are identical as well)
- for each match, go through each provided bake type and execute the bake with the defined parameters
Examples currently unavailable, but can be kickstarted using the Windows 10 examples and the Substance Automation Toolkit documentation.
The code in the provided sample use a modular design so new bake types can be added to the batch process. To add a new bake type:
- define a new "config_<bake_name>.json" and create class to handle it in config_bakes.py
- add the bake rules to the entry.py