# Simple Aggregation pipeline
This example shows how to create a new AggregationPipeline
and how to set basic parameters for Aggregation as well as material baking.
// create a Aggregation Pipeline object
$aggregationPipeline = `SimplygonPipeline -c "AggregationPipeline"`;
// set DefaultTangentCalculatorType to OrthonormalRightHanded (0)
$bResult = `SimplygonPipeline -ss "GlobalSettings/DefaultTangentCalculatorType" -v 0 $aggregationPipeline`;
$defaultTangentCalculatorType = `SimplygonPipeline -gs "GlobalSettings/DefaultTangentCalculatorType" $aggregationPipeline`;
print ("DefaultTangentCalculatorType: " + $defaultTangentCalculatorType + "\n");
// merge geometries
$bResult = `SimplygonPipeline -ss "AggregationProcessor/AggregationSettings/MergeGeometries" -v true $aggregationPipeline`;
$mergeGeometries = `SimplygonPipeline -gs "AggregationProcessor/AggregationSettings/MergeGeometries" $aggregationPipeline`;
print ("MergeGeometries: " + $mergeGeometries + "\n");
// more settings can be set for the Aggregation pipeline,
// see Pipeline documentation and/or inspect the generated file
// that is saved out by this script!
// set bMaterialBake to true to enable material baking,
// if material baking is enabled Simplygon will generate
// a new material (with textures) shared by all the optimized meshes.
$bMaterialBake = true;
if($bMaterialBake == true)
{
// enable material baking
// mapping image is required for material baking
$bResult = `SimplygonPipeline -ss "AggregationProcessor/MappingImageSettings/GenerateMappingImage" -v true $aggregationPipeline`;
$generateMappingImage = `SimplygonPipeline -gs "AggregationProcessor/MappingImageSettings/GenerateMappingImage" $aggregationPipeline`;
print ("GenerateMappingImage: " + $generateMappingImage + "\n");
// in this case we want to generate texture coordinates (UVs)
$bResult = `SimplygonPipeline -ss "AggregationProcessor/MappingImageSettings/GenerateTexCoords" -v true $aggregationPipeline`;
$generateTexCoords = `SimplygonPipeline -gs "AggregationProcessor/MappingImageSettings/GenerateTexCoords" $aggregationPipeline`;
print ("GenerateTexCoords: " + $generateTexCoords + "\n");
// the name of the resulting texture coordinate field
$bResult = `SimplygonPipeline -ss "AggregationProcessor/MappingImageSettings/TexCoordName" -v "MaterialLOD" $aggregationPipeline`;
$texCoordLevel = `SimplygonPipeline -gs "AggregationProcessor/MappingImageSettings/TexCoordName" $aggregationPipeline`;
print ("TexCoordName: " + $texCoordLevel + "\n");
// width of the baked textures
$bResult = `SimplygonPipeline -ss "AggregationProcessor/MappingImageSettings/Output0/TextureWidth" -v 512 $aggregationPipeline`;
$textureWidth = `SimplygonPipeline -gs "AggregationProcessor/MappingImageSettings/Output0/TextureWidth" $aggregationPipeline`;
print ("TextureWidth: " + $textureWidth + "\n");
// height of the baked textures
$bResult = `SimplygonPipeline -ss "AggregationProcessor/MappingImageSettings/Output0/TextureHeight" -v 512 $aggregationPipeline`;
$textureHeight = `SimplygonPipeline -gs "AggregationProcessor/MappingImageSettings/Output0/TextureHeight" $aggregationPipeline`;
print ("TextureHeight: " + $textureHeight + "\n");
// add material casters (ambientColor, color, specularColor and normalCamera)
$bCasterAdded = `SimplygonPipeline -amc "ColorCaster" $aggregationPipeline`;
$bResult = `SimplygonPipeline -ss "MaterialCaster/0/ColorCasterSettings/MaterialChannel" -v "ambientColor" $aggregationPipeline`;
$colorCaster0 = `SimplygonPipeline -gs "MaterialCaster/0/ColorCasterSettings/MaterialChannel" $aggregationPipeline`;
print ("ColorCaster0: " + $colorCaster0 + "\n");
$bCasterAdded = `SimplygonPipeline -amc "ColorCaster" $aggregationPipeline`;
$bResult = `SimplygonPipeline -ss "MaterialCaster/1/ColorCasterSettings/MaterialChannel" -v "color" $aggregationPipeline`;
$colorCaster1 = `SimplygonPipeline -gs "MaterialCaster/1/ColorCasterSettings/MaterialChannel" $aggregationPipeline`;
print ("ColorCaster1: " + $colorCaster1 + "\n");
$bCasterAdded = `SimplygonPipeline -amc "ColorCaster" $aggregationPipeline`;
$bResult = `SimplygonPipeline -ss "MaterialCaster/2/ColorCasterSettings/MaterialChannel" -v "specularColor" $aggregationPipeline`;
$colorCaster2 = `SimplygonPipeline -gs "MaterialCaster/2/ColorCasterSettings/MaterialChannel" $aggregationPipeline`;
print ("ColorCaster2: " + $colorCaster2 + "\n");
// note: normal caster for normals!
$bCasterAdded = `SimplygonPipeline -amc "NormalCaster" $aggregationPipeline`;
$bResult = `SimplygonPipeline -ss "MaterialCaster/3/NormalCasterSettings/MaterialChannel" -v "normalCamera" $aggregationPipeline`;
$normalCaster3 = `SimplygonPipeline -gs "MaterialCaster/3/NormalCasterSettings/MaterialChannel" $aggregationPipeline`;
print ("NormalCaster3: " + $normalCaster3 + "\n");
// set the correct tangent space type,
// in this example we use tangent space normals
$bResult = `SimplygonPipeline -ss "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals" -v true $aggregationPipeline`;
$generateTangentSpaceNormals = `SimplygonPipeline -gs "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals" $aggregationPipeline`;
print ("GenerateTangentSpaceNormals: " + $generateTangentSpaceNormals + "\n");
}
if($bMaterialBake)
{
$bResult = `SimplygonPipeline -s "D:/Pipelines/Aggregation_With_Baking.json" $aggregationPipeline`;
}
else
{
$bResult = `SimplygonPipeline -s "D:/Pipelines/Aggregation.json" $aggregationPipeline`;
}
// clear all pipelines
SimplygonPipeline -cl;
import maya.cmds as cmds
# create a Aggregation Pipeline object
aggregationPipeline = cmds.SimplygonPipeline(c = 'AggregationPipeline')
# set DefaultTangentCalculatorType to OrthonormalRightHanded (0)
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'GlobalSettings/DefaultTangentCalculatorType', v = 0)
defaultTangentCalculatorType = cmds.SimplygonPipeline(aggregationPipeline, gs = 'GlobalSettings/DefaultTangentCalculatorType')
print ('DefaultTangentCalculatorType: ' + defaultTangentCalculatorType + '\n')
# merge geometries
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/AggregationSettings/MergeGeometries', v = True)
mergeGeometries = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/AggregationSettings/MergeGeometries')
print ('MergeGeometries: ' + mergeGeometries + '\n')
# more settings can be set for the Aggregation pipeline,
# see Pipeline documentation and/or inspect the generated file
# that is saved out by this script!
# set bMaterialBake to True to enable material baking,
# if material baking is enabled Simplygon will generate
# a new material (with textures) shared by all the optimized meshes.
bMaterialBake = True
if bMaterialBake:
# enable material baking
# mapping image is required for material baking
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/MappingImageSettings/GenerateMappingImage', v = True)
generateMappingImage = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/MappingImageSettings/GenerateMappingImage')
print ('GenerateMappingImage: ' + generateMappingImage + '\n')
# in this case we want to generate texture coordinates (UVs)
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/MappingImageSettings/GenerateTexCoords', v = True)
generateTexCoords = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/MappingImageSettings/GenerateTexCoords')
print ('GenerateTexCoords: ' + generateTexCoords + '\n')
# the name of the resulting texture coordinate field
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/MappingImageSettings/TexCoordName', v = 'MaterialLOD')
texCoordLevel = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/MappingImageSettings/TexCoordName')
print ('TexCoordName: ' + texCoordLevel + '\n')
# width of the baked textures
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/MappingImageSettings/Output0/TextureWidth', v = 512)
textureWidth = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/MappingImageSettings/Output0/TextureWidth')
print ('TextureWidth: ' + textureWidth + '\n')
# height of the baked textures
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/MappingImageSettings/Output0/TextureHeight', v = 512)
textureHeight = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/MappingImageSettings/Output0/TextureHeight')
print ('TextureHeight: ' + textureHeight + '\n')
# add material casters (ambientColor, color, specularColor and normalCamera)
bCasterAdded = cmds.SimplygonPipeline(aggregationPipeline, amc = 'ColorCaster')
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'MaterialCaster/0/ColorCasterSettings/MaterialChannel', v = 'ambientColor')
colorCaster0 = cmds.SimplygonPipeline(aggregationPipeline, gs = 'MaterialCaster/0/ColorCasterSettings/MaterialChannel')
print ('ColorCaster0: ' + colorCaster0 + '\n')
bCasterAdded = cmds.SimplygonPipeline(aggregationPipeline, amc = 'ColorCaster')
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'MaterialCaster/1/ColorCasterSettings/MaterialChannel', v = 'color')
colorCaster1 = cmds.SimplygonPipeline(aggregationPipeline, gs = 'MaterialCaster/1/ColorCasterSettings/MaterialChannel')
print ('ColorCaster1: ' + colorCaster1 + '\n')
bCasterAdded = cmds.SimplygonPipeline(aggregationPipeline, amc = 'ColorCaster')
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'MaterialCaster/2/ColorCasterSettings/MaterialChannel', v = 'specularColor')
colorCaster2 = cmds.SimplygonPipeline(aggregationPipeline, gs = 'MaterialCaster/2/ColorCasterSettings/MaterialChannel')
print ('ColorCaster2: ' + colorCaster2 + '\n')
# note: normal caster for normals!
bCasterAdded = cmds.SimplygonPipeline(aggregationPipeline, amc = 'NormalCaster')
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'MaterialCaster/3/NormalCasterSettings/MaterialChannel', v = 'normalCamera')
normalCaster3 = cmds.SimplygonPipeline(aggregationPipeline, gs = 'MaterialCaster/3/NormalCasterSettings/MaterialChannel')
print ('NormalCaster3: ' + normalCaster3 + '\n')
# set the correct tangent space type,
# in this example we use tangent space normals
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals', v = True)
generateTangentSpaceNormals = cmds.SimplygonPipeline(aggregationPipeline, gs = 'MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals')
print ('GenerateTangentSpaceNormals: ' + generateTangentSpaceNormals + '\n')
if bMaterialBake:
bResult = cmds.SimplygonPipeline(aggregationPipeline, s = 'D:/Pipelines/Aggregation_With_Baking.json')
else:
bResult = cmds.SimplygonPipeline(aggregationPipeline, s = 'D:/Pipelines/Aggregation.json')
# clear all pipelines
cmds.SimplygonPipeline(cl = True)
# Next steps
Get to know how to use the Aggregation Pipeline: