# SimplygonPipeline
command
# Description
The SimplygonPipeline command is responsible for creating, modifying, importing and exporting of Pipelines / settings. It is recommended to read Pipeline concepts before proceeding.
# Supported Pipelines
Pipeline (API) | Components | Level of support | Description |
---|---|---|---|
ReductionPipeline | ReductionProcessor MaterialCaster | Almost complete | Reduces the geometries Possibility to maintain original materials Possibility to bake materials |
AggregationPipeline | AggregationProcessor MaterialCaster | Almost complete | Aggregates / combines geometries Possibility to maintain original materials Possibility to bake materials |
RemeshingPipeline | RemeshingProcessor MaterialCaster | Almost complete | Creates a replacement geometry Can not preserve original materials Possibility to bake materials |
BillboardCloudPipeline | ImpostorProcessor MaterialCaster | Good | Creates multiple static billboards (outer shell) Possibility to bake materials |
BillboardCloudVegetationPipeline | ImpostorProcessor MaterialCaster | Good | Creates multiple static billboards (within volume) within a threshold Can maintain original material in certain areas Possibility to bake materials |
FlipbookPipeline | ImpostorProcessor MaterialCaster | Pending | Creates a single replacement billboard to be used from multiple directions Possibility to bake materials |
ImpostorFromSingleViewPipeline | ImpostorProcessor MaterialCaster | Almost complete | Creates a single replacement billboard to be used from a specific view direction Possibility to bake materials |
PassthroughPipeline | Almost complete | This pipeline itself does not generate any result, but allows the user to add other pipelines as children (cascaded pipelines). All first level children of this node will be based on the same input. |
# Syntax
# Flags and arguments
Short flag | Long flag | Argument(s) | Description |
---|---|---|---|
c | Create | string pipelineType | Creates a pipeline of the specified type. (see supported pipelines) |
cln | Clone | <none> | Clones the pipeline (created by Create or Load ). |
d | Delete | <none> | Deletes the pipeline (created by Create or Load ). |
cl | Clear | <none> | Clears all pipelines (created by Create or Load ). |
l | Load | string inputPath | Loads a pipeline-file. |
s | Save | string outputPath | Saves pipeline to file (created by Create or Load ). |
ss | SetSetting | string parameterPath <T> parameterValue | Sets the value of the specified pipeline parameter. ( string , bool , int , double , float ) |
gs | GetSetting | string parameterPath | Gets the value of the specified pipeline parameter. |
v | Value | <T> value | Sets the value of the specified pipeline parameter. Should be used in combination with SetSetting . ( string , bool , int , double , float ) |
t | Type | <none> | Gets the type of the specified pipeline. (see supported pipelines) |
a | All | <none> | Gets all pipeline ids that are loaded or created by Create . |
amc | AddMaterialCaster | string casterType | Adds a material-caster to the specified pipeline. ( ColorCaster , NormalCaster , ...) |
acp | AddCascadedPipeline | int pipelineToAdd | Adds a cascaded pipeline to the specified pipeline. |
gcp | GetCascadedPipeline | int childIndex | Gets the child handle of the specified pipeline. |
gcc | GetCascadedPipelineCount | <none> | Gets the child count of the specified pipeline. |
gmc | GetMaterialCasterCount | <none> | Gets the number of material casters for the given pipeline. |
gmt | GetMaterialCasterType | int materialCasterIndex | Gets the type of the material caster for the given pipeline. |
# Examples
This section contains various Pipeline examples written in MEL and Python. We've left out some parts of the scripts to keep things as simple as possible.
import maya.cmds as cmds
must be declared at the top of each Python script.reductionPipeline
settings-path must be declared for both MEL and Python scripts where it makes sense.- a scene-selection is made before each
Simplygon
-command.
# Create a Pipeline object
Creates a ReductionPipeline
, see supported pipelines for more information.
# Load / save a Pipeline object
Loads a Pipeline object from file and then saves it.
Note: Pipeline files should only be used as intermediate and are not intended to be used as presets or templates. Pipeline files are not guaranteed to be compatible with different versions of Simplygon. It is recommended to script Pipelines that saves out Pipeline files rather than loading Pipelines from file.
# Clone a Pipeline object
Clones a ReductionPipeline
.
# Cascaded Pipelines (LOD-chain)
Cascaded pipelines means that each LOD is based on the previous LOD, instead of the original asset which is the standard behavior. In this example we will load two pipelines, one with reduction (LOD1) and one with reduction and baking (LOD2). LOD1 will be based on the original asset and LOD2 will be based on LOD1.
If cascaded pipelines are used in combination with processing from/to file the output scene names will be appended with "_LOD" prefix and then indexed from 1 to *, where the index increments for each cascaded level. The output texture folder for each cascaded scene will be "Textures/LOD1" for LOD1, "Textures/LOD2" for LOD2 and so on. The output file names can be fetched with GetProcessedOutputPaths (gpp) which can then be used at import.
Creates cascaded Pipelines.
# Get / Set Pipeline settings
Pipelines can be created using the SimplygonPipeline
's create-flag
(c
) and the type of the Pipeline to be created. A Pipeline contain settings which reflects the settings for the specific Processor in the Simplygon API. A ReductionPipeline
contains a ReductionProcessor
which contain ReductionSettings
.
MaterialCaster
is a separate object resides inside Pipelines The MaterialCaster object contains settings for material baking.
To set a reduction setting for a ReductionPipeline
, let's say ReductionTargetTriangleRatio
, we will have to pinpoint the path to the specific setting. SimplygonPipeline
is the command we use to work with settings, to set a setting we use the ss
-flag (SetSetting
). The first input is the Pipeline-object, the second is the settings-path and the third is the value we want to set. Fetching a value of a setting works the same way, except that it returns the value of the given settings-path instead of setting it, the flag for fetching a settings value is gs
(GetSetting
).
A settings-path can start with a Processor, MaterialCaster, or any other first level object. In this case we want to set a setting in the ReductionProcessor
, which is the first part of the path, the second part is the settings-object which in this case is ReductionSettings
. And at last, the parameter we want to set is named ReductionTargetTriangleRatio
. Let's set the value of ReductionTargetTriangleRatio
to 50% (0.5).
The same goes for TextureWidth
and TextureHeight
, which are part of the MappingImage
settings-object. In most cases we only use one mapping image, thus Output0
which is allocated by default. Let's set them to 512x512 pixels.
For material baking the initial object is MaterialCaster
, and as there aren't any casters by default they will have to be created with the amc
(AddMaterialCaster
) flag. There after we can use the index and settings of the caster to access its parameters.
Note: The material channels for the MaterialCaster in this example are intended for standard materials in Maya such as Blinn, Phong and Lambert, and might not work for other materials. Additional channels such as incandescence and transparency can be added for baking, for incandescence the ColorCaster is recommended, for transparency the OpacityCaster is recommended (for correct baking of transparent surfaces).
# Cascaded Pipeline settings
Cascaded pipelines are pipelines that depends on other pipelines, let's say that you want to create two LODs where the second LOD (child) uses the first LOD (parent) as reference when optimizing.
If we wish to update a setting deeper down in the hierarchy of pipelines we can use the Cascaded
keyword followed by the index of the child Pipeline, then use the regular settings path for the target pipeline.
Below is an example on how to get / set the TriangleRatio for the first child of the Pipeline, let's assume that the first child is a ReductionPipeline.
We also provide helper flags for fetching the pipeline handle of a cascaded pipeline (first level). This handle is identical to the handle returned by create and load and can be used in same way.
Cascaded Pipelines
Use "GetCascadedPipelineCount" to detect if there are cascaded pipelines and take the appropriate actions. If an error pops up that states that a setting does not exist when trying to read or write values then the pipeline(s) might be structured in a cascaded approach, thus the need to update the setting paths or loop each pipeline individually.
An example of where the pipeline structure might be confusing is when creating pipelines on the same level in the Simplygon UI, all LODs will be based on the original asset and not the previous LOD. In this case we automatically create something called a PassthroughPipeline and then hook in the pipelines specified in the UI as children. So technically this means that there is a hierarchy of pipelines, therefor cascaded and should be treated as such when accessing settings.
# Query material caster settings
In some cases you may want to know the number of material casters, specific settings or simply the type or name of the caster. Below is a short script demonstrating how to list available material casters in a pipeline as well as querying settings. This example is utilizing GetMaterialCasterCount (gmc) and GetMaterialCasterType (gmt) to construct a valid settings path to be used as argument for the GetSetting (gs) flag.
# Multiple LODs based on the same source (using PassthroughPipeline)
Generating multiple LODs that are based on the same source can be achieved quite easily. The first (and most commonly used method) is to simply run Simplygon multiple times on the same asset, but there is always some amount of overhead transfering data back and forth.
Another more efficient way is to set up cascaded pipelines and generate all LODs in one single call. This can be achieved using the PassthroughPipeline which purpose is to offer the user to hook up multiple child pipelines to one single source, the PassthroughPipeline itself does not generate any result. All first level children of the PassthroughPipeline will be based on the same input source.
# Next steps
For more information about Pipelines, visit the links below.