Skip to content
On this page

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.

MEL
// 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;
python
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: ' + str(defaultTangentCalculatorType) + '\n')

# merge geometries
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/AggregationSettings/MergeGeometries', v = True)
mergeGeometries = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/AggregationSettings/MergeGeometries')
print ('MergeGeometries: ' + str(mergeGeometries) + '\n')

# enable geometry culling (hollow shell)
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/AggregationSettings/EnableGeometryCulling', v = True)
enableGeometryCulling = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/AggregationSettings/EnableGeometryCulling')
print ('EnableGeometryCulling: ' + str(enableGeometryCulling) + '\n')

# geometry culling precision (hollow shell)
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/AggregationSettings/GeometryCullingPrecision', v = 0.2)
geometryCullingPrecision = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/AggregationSettings/GeometryCullingPrecision')
print ('GeometryCullingPrecision: ' + str(geometryCullingPrecision) + '\n')

# enable geometry clipping (hollow shell)
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/GeometryCullingSettings/UseClippingGeometry', v = True)
useClippingGeometry = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/GeometryCullingSettings/UseClippingGeometry')
print ('UseClippingGeometry: ' + str(useClippingGeometry) + '\n')

# clipping selection set (hollow shell)
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/GeometryCullingSettings/ClippingGeometrySelectionSetName', v = 'clippingSelectionSet')
clippingGeometrySelectionSetName = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/GeometryCullingSettings/ClippingGeometrySelectionSetName')
print ('ClippingGeometrySelectionSetName: ' + clippingGeometrySelectionSetName + '\n')

# process selection sets
bResult = cmds.SimplygonPipeline(aggregationPipeline, ss = 'AggregationProcessor/AggregationSettings/ProcessSelectionSetName', v = 'processSelectionSet')
processSelectionSetName = cmds.SimplygonPipeline(aggregationPipeline, gs = 'AggregationProcessor/AggregationSettings/ProcessSelectionSetName')
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:
    # 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: ' + str(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: ' + str(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: ' + str(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: ' + str(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: ' + str(generateTangentSpaceNormals) + '\n')

if bMaterialBake:
    bResult = cmds.SimplygonPipeline(aggregationPipeline, s = 'D:/Pipelines/Aggregation_With_Baking_HollowShell.json')
else:
    bResult = cmds.SimplygonPipeline(aggregationPipeline, s = 'D:/Pipelines/Aggregation_HollowShell.json')

# clear all pipelines
cmds.SimplygonPipeline(cl = True)

Next steps

Get to know how to use the Aggregation Pipeline: