# Simple Aggregation pipeline - Hollow shell
This example shows how to use the AggregationPipeline
to combine objects and remove interiors using the geometry culling functionality. Keep in mind that the selection set names listed in this example must exist in Maya for the optimization to work.
Hollow shell functionality can also be achieved by using the AggregationProcessor.
// 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");
// enable geometry culling (hollow shell)
$bResult = `SimplygonPipeline -ss "AggregationProcessor/AggregationSettings/EnableGeometryCulling" -v true $aggregationPipeline`;
$enableGeometryCulling = `SimplygonPipeline -gs "AggregationProcessor/AggregationSettings/EnableGeometryCulling" $aggregationPipeline`;
print ("EnableGeometryCulling: " + $enableGeometryCulling + "\n");
// geometry culling precision (hollow shell)
$bResult = `SimplygonPipeline -ss "AggregationProcessor/AggregationSettings/GeometryCullingPrecision" -v 0.2 $aggregationPipeline`;
$geometryCullingPrecision = `SimplygonPipeline -gs "AggregationProcessor/AggregationSettings/GeometryCullingPrecision" $aggregationPipeline`;
print ("GeometryCullingPrecision: " + $geometryCullingPrecision + "\n");
// enable geometry clipping (hollow shell)
$bResult = `SimplygonPipeline -ss "AggregationProcessor/GeometryCullingSettings/UseClippingGeometry" -v true $aggregationPipeline`;
$useClippingGeometry = `SimplygonPipeline -gs "AggregationProcessor/GeometryCullingSettings/UseClippingGeometry" $aggregationPipeline`;
print ("UseClippingGeometry: " + $useClippingGeometry + "\n");
// clipping selection set (hollow shell)
$bResult = `SimplygonPipeline -ss "AggregationProcessor/GeometryCullingSettings/ClippingGeometrySelectionSetName" -v "clippingSelectionSet" $aggregationPipeline`;
$clippingGeometrySelectionSetName = `SimplygonPipeline -gs "AggregationProcessor/GeometryCullingSettings/ClippingGeometrySelectionSetName" $aggregationPipeline`;
print ("ClippingGeometrySelectionSetName: " + $clippingGeometrySelectionSetName + "\n");
// process selection sets
$bResult = `SimplygonPipeline -ss "AggregationProcessor/AggregationSettings/ProcessSelectionSetName" -v "processSelectionSet" $aggregationPipeline`;
$processSelectionSetName = `SimplygonPipeline -gs "AggregationProcessor/AggregationSettings/ProcessSelectionSetName" $aggregationPipeline`;
print ("ProcessSelectionSetName: " + $processSelectionSetName + "\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_HollowShell.json" $aggregationPipeline`;
}
else
{
$bResult = `SimplygonPipeline -s "D:/Pipelines/Aggregation_HollowShell.json" $aggregationPipeline`;
}
// clear all pipelines
SimplygonPipeline -cl;