- Substance 3D home
- Home
- Command Line Tools
- Command Line overview
- sbsbaker
- sbscooker
- sbsmtools
- sbsmutator
- sbsrender
- sbsupdater
- Command Line overview
- Pysbs - Python API
- Pysbs - Python API overview
- Getting started
- General topics
- Examples
- API Content
- API Content overview
- Substance definitions
- Common interfaces
- compnode
- context projectmgr
- graph
- mdl
- modelgraphindex
- modelannotationnames
- modelgraph
- modelgraphgenerator
- modelgraphimplementation
- modelnodenames
- modeloperand
- modulegraphindex
- moduleannotation
- moduleconnection
- modulegraph
- modulegraphgenerator
- modulegraphimplementation
- modulegraphlibrary
- modulegraphregister
- modulenode
- modulenodeimplementation
- modulenodeinstance
- moduleoperand
- moduleoutputbridging
- moduleparaminput
- params
- projectmgrdoc
- sbsarchive
- sbscommon
- sbspreset
- sbsproject
- substance
- Libraries
- sbsenum
- sbslibrary
- sbsbakerslibrary
- Helpers
- Execution context
- API Change log
- Samples
- Setup and Getting Started
- Integrations
- Substance Maya toolset
- Changelog overview
Variations
Overview
The variations demo shows how a single procedural .sbs file can be used to render out a lot of randomized permutations.The sample substance file is a procedural network for generating brick patterns. It has a few parameters that is randomized by a python script. The output is a set of maps representing the permutations. It also outputs .sbs files with the defaults setup to give the same results as the rendered map in case you want to load a specific permutation a tool.
The data used in the demo are:
- The variations.py script
- batch_utilities.py, demo_cmd.py and demos.py for utility functions
- The substance python api (for finding paths to command line tools and resource library)
- opus.sbs and its resources in the variantions directory
The output will be put in the variations/_outputs directory
In order to run the demo, make sure python is installed and in your path environment and that the substance python api is installed. Then go to the samples directory and run:
python variations.py
It will now invoke a set of calls to different command line tools to generate a set of maps and .sbs files with different parameters.
Note: At the moment the sbs files generated are not identical with what comes out of the sample since the random seed used when generating the textures are not set in the .sbs file defaults.
Details
The source graph opus.sbs might look intimidating at first:
Most of what drives it is a node where an input tiling is selected:
By changing the tiling a number of different patterns can be selected:
There are 4 parameters exposed to control the tiling:
- Pattern Selection refers to what basic tiling to use from a few presets.
- X Amount is a value controlling how many tiles there are in the X direction
- Y Amount is a value controlling how many tiles there are in the Y direction
- Crack Scale represents how large the cracks in the tiling should be
In the file variations.py there is a definition for how the parameters should be tweaked during the permutation creation. In the case of the opus graph we randomize the values in ranges that makes sense for the graph.
materials = { 'opus' : { 'sbs_file' : os.path.join(data_path, 'opus.sbs'), 'params' : { 'pattern_selection' : ('random_int', [1], [5]), 'x_amount' : ('random_int', [5], [10]), 'y_amount' : ('random_int', [5], [10]), 'crack_scale' : ('random_int', [2], [4]), } }}
- When running the script it will first cook opus sbs to an sbsar file ready to be rendered.
- It will then put a bunch of calls to sbsrender and sbsmutator in a queue for rendering.
- It will then let a thread pool execute all these jobs to output the images in a multithreaded fashion if running on a multi core machine.
The output in the variations/_output will then be filled up with new maps and substance files: