# Pipeline functions

A fundamental change of the 9.0 3DS Max plug-in is the new Pipeline settings system that was introduced in Simplygon 9.0. SPL- and Preset-files are from here on no longer supported. Pipeline-objects has a one-to-one settings mapping to the Simplygon API, please refer to the API documentation for information about individual settings. Pipeline script functions are exposed in 3DS Max which allows the user to create and modify Pipeline-files programmatically, providing unprecedented flexibility and direct access for all users.

Note: Pipeline files are intended to be used as intermediate communication layer while processing, the files may not be compatible between different versions of Simplygon. A safer method is to work with scripts that generates Pipelines, then at runtime exporting Pipelines to file, if needed.

The complete list of script functions are listed below.

Function Parameter(s) Description
sgsdk_RunPipelineOnSelection int pipelineType Optimizes the selected asset(s) based on the pipeline object.
sgsdk_RunPipelineOnSelection string pipelineFilePath Optimizes the selected asset(s) based on the pipeline file.
sgsdk_CreatePipeline string pipelineType Creates a pipeline of the specified type.
sgsdk_DeletePipeline int pipelineId Deletes the pipeline.
(created from sgsdk_CreatePipeline or sgsdk_LoadPipeline).
sgsdk_ClearPipelines <none> Clears all pipelines that are currently loaded.
(created from sgsdk_CreatePipeline or sgsdk_LoadPipeline).
sgsdk_LoadPipeline string inputPath Loads a pipeline-file.
sgsdk_SavePipeline int pipelineId
string outputPath
Saves pipeline to file.
sgsdk_SetSetting int pipelineId
string parameterPath
<T> parameterValue
Sets the value of the specified pipeline parameter.
(string, bool, int, double, float)
sgsdk_GetSetting int pipelineId
string parameterPath
Gets the value of the specified pipeline parameter.
sgsdk_GetPipelineType int pipelineId Gets the type of the specified pipeline.
(ReductionPipeline, AggregationPipeline, RemeshingPipeline, ...)
sgsdk_GetPipelines <none> Gets all pipeline ids that are currently loaded.
(created from sgsdk_CreatePipeline or sgsdk_LoadPipeline).
sgsdk_AddMaterialCaster int pipelineId
string materialCasterType
Adds a material-caster to the specified pipeline.
(ColorCaster, NormalCaster, ...)
sgsdk_AddCascadedPipeline int pipelineId
int pipelineToAdd
Adds a cascaded pipeline to the specified pipeline.

# Examples

This section contains various Pipeline examples written in MaxScript and Python. We've left out some parts of the scripts to keep things as simple as possible.

  • from pymxs import runtime as rt must be declared at the top of each Python script.
  • reductionPipeline settings-path must be declared for both MaxScript and Python scripts where it makes sense.
  • a scene-selection is made before each sgsdk_RunPipelineOnSelection.

# Create a Pipeline object

Creates a ReductionPipeline, other supported pipelines are AggregationPipeline, RemeshingPipeline and RemeshingLegacyPipeline.

MaxScript

reductionPipeline = sgsdk_CreatePipeline "ReductionPipeline"

Python

from pymxs import runtime as rt

reductionPipeline = rt.sgsdk_CreatePipeline('ReductionPipeline')

# 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.

MaxScript

reductionPipeline = sgsdk_LoadPipeline "D:/Pipelines/reductionPipeline.json"
sgsdk_SavePipeline reductionPipeline "D:/Pipelines/reductionPipeline.json"

Python

from pymxs import runtime as rt

reductionPipeline = rt.sgsdk_LoadPipeline('D:/Pipelines/reductionPipeline.json')
rt.sgsdk_SavePipeline(reductionPipeline, 'D:/Pipelines/reductionPipeline.json')

# 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.

MaxScript

-- loads two different pipelines
reductionPipeline = sgsdk_LoadPipeline "D:/Pipelines/reductionPipeline.json"
reductionPipelineWithBaking = sgsdk_LoadPipeline "D:/Pipelines/reductionPipelineWithBaking.json"

-- adds reduction with baking as cascaded pipeline using AddCascadedPipeline
bResult = sgsdk_AddCascadedPipeline reductionPipeline reductionPipelineWithBaking

-- save new cascaded pipeline to disk
bResult = sgsdk_SavePipeline reductionPipeline "D:/Pipelines/cascadedReductionPipeline.json"

Python

from pymxs import runtime as rt

# loads two different pipelines
reductionPipeline = rt.sgsdk_LoadPipeline('D:/Pipelines/reductionPipeline.json')
reductionPipelineWithBaking = rt.sgsdk_LoadPipeline('D:/Pipelines/reductionPipelineWithBaking.json')

# adds reduction with baking as cascaded pipeline using AddCascadedPipeline
bResult = rt.sgsdk_AddCascadedPipeline(reductionPipeline, reductionPipelineWithBaking)

# save new cascaded pipeline to disk
bResult = sgsdk_SavePipeline(reductionPipeline, 'D:/Pipelines/cascadedReductionPipeline.json')

# Get / Set Pipeline settings

Currently we support four Pipelines: ReductionPipeline, AggregationPipeline, RemeshingPipeline and RemeshingV2Pipeline. These Pipelines can be created with sgsdk_CreatePipeline in combination with the type name of the Pipeline.

Each Pipeline has settings which reflects the settings of the specific Processor in the Simplygon API. ReductionPipeline contains a ReductionProcessor which contains ReductionSettings while the RemeshingProcessor has RemeshingSettings.

MaterialCaster is a separate object that is located inside the Pipelines and contains settings for material baking. All of the Pipelines above has the ability to bake materials.

To set a reduction setting for a ReductionPipeline, let's say ReductionTargetTriangleRatio, we will have to pinpoint the path to the specific setting. sgsdk_SetSetting is function we use to work with settings. 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 function for fetching a settings value is sgsdk_GetSetting.

A settings-path can start with a Processor, MaterialCaster, or any other first level object depending on the Pipeline. 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).

MaxScript

-- sets the ReductionTargetTriangleRatio for the given ReductionPipeline
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetTriangleRatio" 0.5

-- gets the ReductionTargetTriangleRatio from the given ReductionPipeline
reductionTargetTriangleRatio = sgsdk_GetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetTriangleRatio"

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.

MaxScript

-- sets the texture-width for the given ReductionPipeline
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/Output0/TextureWidth" 512 

-- gets the texture-width for the given ReductionPipeline
textureWidth = sgsdk_GetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/Output0/TextureWidth"

-- sets the texture-height for the given ReductionPipeline
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/Output0/TextureHeight" 512

-- gets the texture-height for the given ReductionPipeline
textureHeight = sgsdk_GetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/Output0/TextureHeight"

For material baking the initial object is MaterialCaster, and as there aren't any casters by default they will have to be created with sgsdk_AddMaterialCaster. 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 Max such as Blinn and Phong, and might not work for other materials. Additional channels such as opacity can be added for baking, for Opacity the OpacityCaster is recommended (for correct baking of transparent surfaces).

MaxScript

-- add a ColorCaster to the given ReductionPipeline
bCasterAdded = sgsdk_AddMaterialCaster reductionPipeline "ColorCaster"

-- set the MaterialChannel to "Diffuse_Color" for the given ColorCaster
bResult = sgsdk_SetSetting reductionPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel" "Diffuse_Color"

-- get the MaterialChannel for the given ColorCaster
colorCaster0 = sgsdk_GetSetting reductionPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel"

-- add a NormalCaster to the given ReductionPipeline
bCasterAdded = sgsdk_AddMaterialCaster reductionPipeline "NormalCaster"

-- set the MaterialChannel to "Bump" for the given NormalCaster
bResult = sgsdk_SetSetting reductionPipeline "MaterialCaster/1/NormalCasterSettings/MaterialChannel" "Bump"

-- get the MaterialChannel for the given NormalCaster
normalCaster1 = sgsdk_GetSetting reductionPipeline "MaterialCaster/1/NormalCasterSettings/MaterialChannel"

-- set the tangent-space flag for the given NormalCaster
bResult = sgsdk_SetSetting reductionPipeline "MaterialCaster/1/NormalCasterSettings/GenerateTangentSpaceNormals" true

-- get the tangent-space flag for the given NormalCaster
generateTangentSpaceNormals = sgsdk_GetSetting reductionPipeline "MaterialCaster/1/NormalCasterSettings/GenerateTangentSpaceNormals"

For more information about the structure of Pipelines, see the Pipeline API documentation. There are also four examples on how to create a ReductionPipeline, AggregationPipeline, RemeshingPipeline and RemeshingLegacyPipeline and set some of its settings at the end of this document.

# Vertex colors as vertex weights

Vertex weights can be used to tell the reduction which parts of the mesh that are important and which are not. Weights can also be used when baking materials, or rather to change the size of the UVs which will affect how much texture space gets used for given parts of the mesh. An example where weights can be applied is when you would want to preserve details on a character, such as nose and eyes.

Creates a ReductionPipeline that will use the specified color-set as vertex weights.

MaxScript

-- creates a reduction pipeline
reductionPipeline = sgsdk_CreatePipeline "ReductionPipeline"
...

-- enables vertex weights in reducer
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/VertexWeightSettings/UseVertexWeightsInReducer" true

-- enables vertex weights in material caster
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/VertexWeightSettings/UseVertexWeightsInTexcoordGenerator" true

-- sets which vertex-color-set to be used as weights
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/VertexWeightSettings/WeightsFromColorName" "3"

Python

from pymxs import runtime as rt

# creates a reduction pipeline
reductionPipeline = rt.sgsdk_CreatePipeline('ReductionPipeline')
...

# enables vertex weights in material caster
bResult = rt.sgsdk_SetSetting(reductionPipeline, 'ReductionProcessor/VertexWeightSettings/UseVertexWeightsInTexcoordGenerator', True)

# sets which vertex-color-set to be used as weights
bResult = rt.sgsdk_SetSetting(reductionPipeline, 'ReductionProcessor/VertexWeightSettings/WeightsFromColorName', '3')

Sets the strength (multiplier) of the weights.

MaxScript

-- sets the strength of the weights (2 is low, 8 is high, 4 is default)
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/VertexWeightSettings/WeightsFromColorMultiplier" 8

Python

from pymxs import runtime as rt

# sets the strength of the weights (2 is low, 8 is high, 4 is default)
bResult = rt.sgsdk_SetSetting(reductionPipeline, 'ReductionProcessor/VertexWeightSettings/WeightsFromColorMultiplier', 8)

Sets the color component to use as weights.

MaxScript

-- sets the color component to use as weights (R = 0, G = 1, B = 2, A = 3, default = 0)
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/VertexWeightSettings/WeightsFromColorComponent" 0

Python

from pymxs import runtime as rt

# sets the color component to use as weights (R = 0, G = 1, B = 2, A = 3, default = 0)
bResult = rt.sgsdk_SetSetting(reductionPipeline, 'ReductionProcessor/VertexWeightSettings/WeightsFromColorComponent', 0)

The weights color mode (previously interpreter) can be used to change the interpretation of weights.

0 Black: reduce more | White: reduce less
1 Black: unchanged | White: reduce less
2 Black: reduce more | White: unchanged

Sets the weights color mode.

MaxScript

-- sets the color mode for weights (default = 0)
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/VertexWeightSettings/WeightsFromColorMode" 0

Python

from pymxs import runtime as rt

# sets the color mode for weights (default = 0)
bResult = rt.sgsdk_SetSetting(reductionPipeline, ss = 'ReductionProcessor/VertexWeightSettings/WeightsFromColorMode', 0)

# Run pipeline

MaxScript

-- reset
sgsdk_Reset()

-- load an asset
loadMaxFile "D:/Assets/theAsset.max"

-- select everything in scene
select $*

-- load a previously saved pipeline
reductionPipeline = sgsdk_LoadPipeline "D:/Pipelines/reductionPipeline.json"

-- execute pipeline on selection 
-- returns result to Max once completed
sgsdk_RunPipelineOnSelection reductionPipeline 

-- clear all pipelines
sgsdk_ClearPipelines()

Python

from pymxs import runtime as rt

# reset
rt.sgsdk_Reset()

# load an asset
rt.loadMaxFile('D:/Assets/theAsset.max')

# select everything in scene
rt.select(rt.objects)

# load a previously saved pipeline
reductionPipeline = rt.sgsdk_LoadPipeline('D:/Pipelines/reductionPipeline.json')

# execute pipeline on selection
# returns result to Max once completed
rt.sgsdk_RunPipelineOnSelection(reductionPipeline)

# clear all pipelines
rt.sgsdk_ClearPipelines()

# Simple Reduction pipeline

This example shows how to create a new ReductionPipeline and how to set basic parameters for reduction and material baking.

MaxScript

-- create a Reduction Pipeline object
reductionPipeline = sgsdk_CreatePipeline "ReductionPipeline"

-- set DefaultTangentCalculatorType to Autodesk3dsMax (1)
bResult = sgsdk_SetSetting reductionPipeline "GlobalSettings/DefaultTangentCalculatorType" 1
defaultTangentCalculatorType = sgsdk_GetSetting reductionPipeline "GlobalSettings/DefaultTangentCalculatorType"
print ("DefaultTangentCalculatorType: " + defaultTangentCalculatorType as string + "\n")

-- set the triangle ratio to 50%
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetTriangleRatio" 0.5
reductionTargetTriangleRatio = sgsdk_GetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetTriangleRatio"
print ("ReductionTargetTriangleRatio: " + reductionTargetTriangleRatio as string + "\n")

-- set the reduction target to triangle ratio
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetTriangleRatioEnabled" true
reductionTargetTriangleRatioEnabled = sgsdk_GetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetTriangleRatioEnabled"
print ("ReductionTargetTriangleRatioEnabled: " + reductionTargetTriangleRatioEnabled as string + "\n")

-- disable triangle count reduction target
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetTriangleCountEnabled" false
reductionTargetTriangleCountEnabled = sgsdk_GetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetTriangleCountEnabled"
print ("ReductionTargetTriangleCountEnabled: " + reductionTargetTriangleCountEnabled as string + "\n")

-- disable max deviation reduction target
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetMaxDeviationEnabled" false
reductionTargetMaxDeviationEnabled = sgsdk_GetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetMaxDeviationEnabled"
print ("ReductionTargetMaxDeviationEnabled: " + reductionTargetMaxDeviationEnabled as string + "\n")

-- disable onscreensize reduction target
bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetOnScreenSizeEnabled" false
reductionTargetOnScreenSizeEnabled = sgsdk_GetSetting reductionPipeline "ReductionProcessor/ReductionSettings/ReductionTargetOnScreenSizeEnabled"
print ("ReductionTargetOnScreenSizeEnabled: " + reductionTargetOnScreenSizeEnabled as string + "\n")

-- more settings can be set for the Reduction 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 do
(
    -- enable material baking
    -- mapping image is required for material baking
    bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/GenerateMappingImage" true
    generateMappingImage = sgsdk_GetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/GenerateMappingImage"
    print ("GenerateMappingImage: " + generateMappingImage as string + "\n")

    -- in this case we want to generate texture coordinates (UVs)
    bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/GenerateTexCoords" true
    generateTexCoords = sgsdk_GetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/GenerateTexCoords"
    print ("GenerateTexCoords: " + generateTexCoords as string + "\n")

    -- the name of the resulting texture coordinate field
    bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/TexCoordName" "MaterialLOD"
    texCoordLevel = sgsdk_GetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/TexCoordName"
    print ("TexCoordName: " + texCoordLevel as string + "\n")

    -- width of the baked textures
    bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/Output0/TextureWidth" 512
    textureWidth = sgsdk_GetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/Output0/TextureWidth"
    print ("TextureWidth: " + textureWidth as string + "\n")

    -- height of the baked textures
    bResult = sgsdk_SetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/Output0/TextureHeight" 512
    textureHeight = sgsdk_GetSetting reductionPipeline "ReductionProcessor/MappingImageSettings/Output0/TextureHeight"
    print ("TextureHeight: " + textureHeight as string + "\n")

    -- add material casters (Ambient_Color, Diffuse_Color, Specular_Color and Bump)
    bCasterAdded = sgsdk_AddMaterialCaster reductionPipeline "ColorCaster"
    bResult = sgsdk_SetSetting reductionPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel" "Ambient_Color"
    colorCaster0 = sgsdk_GetSetting reductionPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster0: " + colorCaster0 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster reductionPipeline "ColorCaster"
    bResult = sgsdk_SetSetting reductionPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel" "Diffuse_Color"
    colorCaster1 = sgsdk_GetSetting reductionPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster1: " + colorCaster1 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster reductionPipeline "ColorCaster"
    bResult = sgsdk_SetSetting reductionPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel" "Specular_Color"
    colorCaster2 = sgsdk_GetSetting reductionPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster2: " + colorCaster2 as string + "\n")

    -- note: normal caster for normals!
    bCasterAdded = sgsdk_AddMaterialCaster reductionPipeline "NormalCaster"
    bResult = sgsdk_SetSetting reductionPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel" "Bump"
    normalCaster3 = sgsdk_GetSetting reductionPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel"
    print ("NormalCaster3: " + normalCaster3 as string + "\n")

    -- set the correct tangent space type,
    -- in this example we use tangent space normals
    bResult = sgsdk_SetSetting reductionPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals" true
    generateTangentSpaceNormals = sgsdk_GetSetting reductionPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals"
    print ("GenerateTangentSpaceNormals: " + generateTangentSpaceNormals as string + "\n")
)

-- save the generated Pipeline object to file for later use
bResult = sgsdk_SavePipeline reductionPipeline "D:/Pipelines/Reduction_With_Baking.json"

-- clear all pipelines
sgsdk_ClearPipelines()

# 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.

MaxScript

-- create a Aggregation Pipeline object
aggregationPipeline = sgsdk_CreatePipeline "AggregationPipeline"

-- set DefaultTangentCalculatorType to Autodesk3dsMax (1)
bResult = sgsdk_SetSetting aggregationPipeline "GlobalSettings/DefaultTangentCalculatorType" 1
defaultTangentCalculatorType = sgsdk_GetSetting aggregationPipeline "GlobalSettings/DefaultTangentCalculatorType"
print ("DefaultTangentCalculatorType: " + defaultTangentCalculatorType as string + "\n")

-- merge geometries
bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/MergeGeometries" true
mergeGeometries = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/MergeGeometries"
print ("MergeGeometries: " + mergeGeometries as string + "\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 then
(
    -- enable material baking
    -- mapping image is required for material baking
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/GenerateMappingImage" true
    generateMappingImage = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/GenerateMappingImage"
    print ("GenerateMappingImage: " + generateMappingImage as string + "\n")

    -- in this case we want to generate texture coordinates (UVs)
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/GenerateTexCoords" true
    generateTexCoords = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/GenerateTexCoords"
    print ("GenerateTexCoords: " + generateTexCoords as string + "\n")

    -- the name of the resulting texture coordinate field
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/TexCoordName" "MaterialLOD"
    texCoordLevel = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/TexCoordName"
    print ("TexCoordName: " + texCoordLevel as string + "\n")

    -- width of the baked textures
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/Output0/TextureWidth" 512
    textureWidth = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/Output0/TextureWidth"
    print ("TextureWidth: " + textureWidth as string + "\n")

    -- height of the baked textures
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/Output0/TextureHeight" 512
    textureHeight = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/Output0/TextureHeight"
    print ("TextureHeight: " + textureHeight as string + "\n")

    -- add material casters (Ambient_Color, Diffuse_Color, Specular_Color and Bump)
    bCasterAdded = sgsdk_AddMaterialCaster aggregationPipeline "ColorCaster"
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel" "Ambient_Color"
    colorCaster0 = sgsdk_GetSetting aggregationPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster0: " + colorCaster0 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster aggregationPipeline "ColorCaster"
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel" "Diffuse_Color"
    colorCaster1 = sgsdk_GetSetting aggregationPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster1: " + colorCaster1 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster aggregationPipeline "ColorCaster"
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel" "Specular_Color"
    colorCaster2 = sgsdk_GetSetting aggregationPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster2: " + colorCaster2 as string + "\n")

    -- note: normal caster for normals!
    bCasterAdded = sgsdk_AddMaterialCaster aggregationPipeline "NormalCaster"
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel" "Bump"
    normalCaster3 = sgsdk_GetSetting aggregationPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel"
    print ("NormalCaster3: " + normalCaster3 as string + "\n")

    -- set the correct tangent space type,
    -- in this example we use tangent space normals
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals" true
    generateTangentSpaceNormals = sgsdk_GetSetting aggregationPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals"
    print ("GenerateTangentSpaceNormals: " + generateTangentSpaceNormals as string + "\n")
)

bResult = sgsdk_SavePipeline aggregationPipeline "D:/Pipelines/Aggregation_With_Baking.json"

-- clear all pipelines
sgsdk_ClearPipelines()

# 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 Max for the optimization to work.

Hollow shell functionality can also be achieved by using the AggregationProcessor.

MaxScript

-- create a Aggregation Pipeline object
aggregationPipeline = sgsdk_CreatePipeline "AggregationPipeline"

-- set DefaultTangentCalculatorType to Autodesk3dsMax (1)
bResult = sgsdk_SetSetting aggregationPipeline "GlobalSettings/DefaultTangentCalculatorType" 1
defaultTangentCalculatorType = sgsdk_GetSetting aggregationPipeline "GlobalSettings/DefaultTangentCalculatorType"
print ("DefaultTangentCalculatorType: " + defaultTangentCalculatorType as string + "\n")

-- merge geometries
bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/MergeGeometries" true
mergeGeometries = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/MergeGeometries"
print ("MergeGeometries: " + mergeGeometries as string + "\n")

-- enable geometry culling (hollow shell)
bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/EnableGeometryCulling" true
enableGeometryCulling = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/EnableGeometryCulling"
print ("EnableGeometryCulling: " + enableGeometryCulling as string + "\n")

-- geometry culling precision (hollow shell)
bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/GeometryCullingPrecision" 0.2
geometryCullingPrecision = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/GeometryCullingPrecision"
print ("GeometryCullingPrecision: " + geometryCullingPrecision as string + "\n")

-- enable geometry clipping (hollow shell)
bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/GeometryCullingSettings/UseClippingGeometry" true
useClippingGeometry = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/GeometryCullingSettings/UseClippingGeometry"
print ("UseClippingGeometry: " + useClippingGeometry as string + "\n")

-- clipping selection set (hollow shell)
bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/GeometryCullingSettings/ClippingGeometrySelectionSetName" "clippingSelectionSet"
clippingGeometrySelectionSetName = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/GeometryCullingSettings/ClippingGeometrySelectionSetName"
print ("ClippingGeometrySelectionSetName: " + clippingGeometrySelectionSetName as string + "\n")

-- process selection sets
bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/ProcessSelectionSetName" "processSelectionSet"
processSelectionSetName = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/AggregationSettings/ProcessSelectionSetName"
print ("ProcessSelectionSetName: " + processSelectionSetName as string + "\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 then
(
    -- enable material baking
    -- mapping image is required for material baking
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/GenerateMappingImage" true
    generateMappingImage = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/GenerateMappingImage"
    print ("GenerateMappingImage: " + generateMappingImage as string + "\n")

    -- in this case we want to generate texture coordinates (UVs)
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/GenerateTexCoords" true
    generateTexCoords = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/GenerateTexCoords"
    print ("GenerateTexCoords: " + generateTexCoords as string + "\n")

    -- the name of the resulting texture coordinate field
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/TexCoordName" "MaterialLOD"
    texCoordLevel = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/TexCoordName"
    print ("TexCoordName: " + texCoordLevel as string + "\n")

    -- width of the baked textures
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/Output0/TextureWidth" 512
    textureWidth = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/Output0/TextureWidth"
    print ("TextureWidth: " + textureWidth as string + "\n")

    -- height of the baked textures
    bResult = sgsdk_SetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/Output0/TextureHeight" 512
    textureHeight = sgsdk_GetSetting aggregationPipeline "AggregationProcessor/MappingImageSettings/Output0/TextureHeight"
    print ("TextureHeight: " + textureHeight as string + "\n")

    -- add material casters (Ambient_Color, Diffuse_Color, Specular_Color and Bump)
    bCasterAdded = sgsdk_AddMaterialCaster aggregationPipeline "ColorCaster"
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel" "Ambient_Color"
    colorCaster0 = sgsdk_GetSetting aggregationPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster0: " + colorCaster0 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster aggregationPipeline "ColorCaster"
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel" "Diffuse_Color"
    colorCaster1 = sgsdk_GetSetting aggregationPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster1: " + colorCaster1 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster aggregationPipeline "ColorCaster"
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel" "Specular_Color"
    colorCaster2 = sgsdk_GetSetting aggregationPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster2: " + colorCaster2 as string + "\n")

    -- note: normal caster for normals!
    bCasterAdded = sgsdk_AddMaterialCaster aggregationPipeline "NormalCaster"
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel" "Bump"
    normalCaster3 = sgsdk_GetSetting aggregationPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel"
    print ("NormalCaster3: " + normalCaster3  as string + "\n")

    -- set the correct tangent space type,
    -- in this example we use tangent space normals
    bResult = sgsdk_SetSetting aggregationPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals" true
    generateTangentSpaceNormals = sgsdk_GetSetting aggregationPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals"
    print ("GenerateTangentSpaceNormals: " + generateTangentSpaceNormals as string + "\n")
)

bResult = sgsdk_SavePipeline aggregationPipeline "D:/Pipelines/Aggregation_With_Baking.json"

-- clear all pipelines
sgsdk_ClearPipelines()

# Simple Remeshing pipeline (new remesher)

This example shows how to create a new RemeshingPipeline and how to set basic parameters for Remeshing and material baking.

MaxScript

-- create a Remeshing Pipeline object
remeshingPipeline = sgsdk_CreatePipeline "RemeshingPipeline"

-- set DefaultTangentCalculatorType to Autodesk3dsMax (1)
bResult = sgsdk_SetSetting remeshingPipeline "GlobalSettings/DefaultTangentCalculatorType" 1
defaultTangentCalculatorType = sgsdk_GetSetting remeshingPipeline "GlobalSettings/DefaultTangentCalculatorType"
print ("DefaultTangentCalculatorType: " + defaultTangentCalculatorType as string + "\n")

-- set the OnScreenSize for the generated mesh
bResult = sgsdk_SetSetting remeshingPipeline "RemeshingProcessor/RemeshingSettings/OnScreenSize" 300
onScreenSize = sgsdk_GetSetting remeshingPipeline "RemeshingProcessor/RemeshingSettings/OnScreenSize"
print ("OnScreenSize: " + onScreenSize as string + "\n")

-- Hole filling defines how deep cavities that should be filled are allowed to be, 
-- and how large the openings of the holes and cavities the processor will attempt to fill will be.
-- 0 = no hole filling, 1 = low, 2 = medium, 3 = high
bResult = sgsdk_SetSetting remeshingPipeline "RemeshingProcessor/RemeshingSettings/HoleFilling" 1
holeFilling = sgsdk_GetSetting remeshingPipeline "RemeshingProcessor/RemeshingSettings/HoleFilling"
print ("HoleFilling: " + holeFilling as string + "\n")
            
-- more settings can be set for the Remeshing 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) for the generated mesh.
bMaterialBake = true
if bMaterialBake == true then
(
    -- enable material baking
    -- mapping image is required for material baking
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/GenerateMappingImage" true
    generateMappingImage = sgsdk_GetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/GenerateMappingImage"
    print ("GenerateMappingImage: " + generateMappingImage as string + "\n")

    -- in this case we want to generate texture coordinates (UVs)
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/GenerateTexCoords" true
    generateTexCoords = sgsdk_GetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/GenerateTexCoords"
    print ("GenerateTexCoords: " + generateTexCoords as string + "\n")

    -- the name of the resulting texture coordinate field
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/TexCoordName" "MaterialLOD"
    texCoordLevel = sgsdk_GetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/TexCoordName"
    print ("TexCoordName: " + texCoordLevel as string + "\n")

    -- width of the baked textures
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/Output0/TextureWidth" 512
    textureWidth = sgsdk_GetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/Output0/TextureWidth"
    print ("TextureWidth: " + textureWidth as string + "\n")

    -- height of the baked textures
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/Output0/TextureHeight" 512
    textureHeight = sgsdk_GetSetting remeshingPipeline "RemeshingProcessor/MappingImageSettings/Output0/TextureHeight"
    print ("TextureHeight: " + textureHeight as string + "\n")

    -- add material casters (Ambient_Color, Diffuse_Color, Specular_Color and Bump)
    bCasterAdded = sgsdk_AddMaterialCaster remeshingPipeline "ColorCaster"
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel" "Ambient_Color"
    colorCaster0 = sgsdk_GetSetting remeshingPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster0: " + colorCaster0 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster remeshingPipeline "ColorCaster"
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel" "Diffuse_Color"
    colorCaster1 = sgsdk_GetSetting remeshingPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster1: " + colorCaster1 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster remeshingPipeline "ColorCaster"
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel" "Specular_Color"
    colorCaster2 = sgsdk_GetSetting remeshingPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster2: " + colorCaster2 as string + "\n")

    -- note: normal caster for normals!
    bCasterAdded = sgsdk_AddMaterialCaster remeshingPipeline "NormalCaster"
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel" "Bump"
    normalCaster3 = sgsdk_GetSetting remeshingPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel"
    print ("NormalCaster3: " + normalCaster3 as string + "\n")

    -- set the correct tangent space type,
    -- in this example we use tangent space normals
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals" true
    generateTangentSpaceNormals = sgsdk_GetSetting remeshingPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals"
    print ("GenerateTangentSpaceNormals: " + generateTangentSpaceNormals as string + "\n")
)

bResult = sgsdk_SavePipeline remeshingPipeline "D:/Pipelines/RemeshingV2_With_Baking.json"

-- clear all pipelines
sgsdk_ClearPipelines()

# Simple Remeshing pipeline (old remesher)

This example shows how to create a new RemeshingLegacyPipeline and how to set basic parameters for Remeshing and material baking.

MaxScript

-- create a Remeshing Pipeline object
remeshingPipeline = sgsdk_CreatePipeline "RemeshingLegacyPipeline"

-- set DefaultTangentCalculatorType to Autodesk3dsMax (1)
bResult = sgsdk_SetSetting remeshingPipeline "GlobalSettings/DefaultTangentCalculatorType" 1
defaultTangentCalculatorType = sgsdk_GetSetting remeshingPipeline "GlobalSettings/DefaultTangentCalculatorType"
print ("DefaultTangentCalculatorType: " + defaultTangentCalculatorType as string + "\n")

-- set the OnScreenSize for the generated mesh
bResult = sgsdk_SetSetting remeshingPipeline "RemeshingLegacyProcessor/RemeshingLegacySettings/OnScreenSize" 300
onScreenSize = sgsdk_GetSetting remeshingPipeline "RemeshingLegacyProcessor/RemeshingLegacySettings/OnScreenSize"
print ("OnScreenSize: " + onScreenSize as string + "\n")

-- set the merge distance for the Remeshing processor,
-- a lower value might be preferred for skinned assets to avoid small gaps to merge,
-- or when you want to preserve details (at a cost of triangles).
bResult = sgsdk_SetSetting remeshingPipeline "RemeshingLegacyProcessor/RemeshingLegacySettings/MergeDistance" 0
mergeDistance = sgsdk_GetSetting remeshingPipeline "RemeshingLegacyProcessor/RemeshingLegacySettings/MergeDistance"
print ("MergeDistance: " + mergeDistance as string + "\n")

-- more settings can be set for the Remeshing 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) for the generated mesh.
bMaterialBake = true
if bMaterialBake == true then
(
    -- enable material baking
    -- mapping image is required for material baking
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/GenerateMappingImage" true
    generateMappingImage = sgsdk_GetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/GenerateMappingImage"
    print ("GenerateMappingImage: " + generateMappingImage as string + "\n")

    -- in this case we want to generate texture coordinates (UVs)
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/GenerateTexCoords" true
    generateTexCoords = sgsdk_GetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/GenerateTexCoords"
    print ("GenerateTexCoords: " + generateTexCoords as string + "\n")

    -- the name of the resulting texture coordinate field
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/TexCoordName" "MaterialLOD"
    texCoordLevel = sgsdk_GetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/TexCoordName"
    print ("TexCoordName: " + texCoordLevel as string + "\n")

    -- width of the baked textures
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureWidth" 512
    textureWidth = sgsdk_GetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureWidth"
    print ("TextureWidth: " + textureWidth as string + "\n")

    -- height of the baked textures
    bResult = sgsdk_SetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureHeight" 512
    textureHeight = sgsdk_GetSetting remeshingPipeline "RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureHeight"
    print ("TextureHeight: " + textureHeight as string + "\n")

    -- add material casters (Ambient_Color, Diffuse_Color, Specular_Color and Bump)
    bCasterAdded = sgsdk_AddMaterialCaster remeshingPipeline "ColorCaster"
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel" "Ambient_Color"
    colorCaster0 = sgsdk_GetSetting remeshingPipeline "MaterialCaster/0/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster0: " + colorCaster0 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster remeshingPipeline "ColorCaster"
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel" "Diffuse_Color"
    colorCaster1 = sgsdk_GetSetting remeshingPipeline "MaterialCaster/1/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster1: " + colorCaster1 as string + "\n")

    bCasterAdded = sgsdk_AddMaterialCaster remeshingPipeline "ColorCaster"
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel" "Specular_Color"
    colorCaster2 = sgsdk_GetSetting remeshingPipeline "MaterialCaster/2/ColorCasterSettings/MaterialChannel"
    print ("ColorCaster2: " + colorCaster2 as string + "\n")

    -- note: normal caster for normals!
    bCasterAdded = sgsdk_AddMaterialCaster remeshingPipeline "NormalCaster"
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel" "Bump"
    normalCaster3 = sgsdk_GetSetting remeshingPipeline "MaterialCaster/3/NormalCasterSettings/MaterialChannel"
    print ("NormalCaster3: " + normalCaster3 as string + "\n")

    -- set the correct tangent space type,
    -- in this example we use tangent space normals
    bResult = sgsdk_SetSetting remeshingPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals" true
    generateTangentSpaceNormals = sgsdk_GetSetting remeshingPipeline "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals"
    print ("GenerateTangentSpaceNormals: " + generateTangentSpaceNormals as string + "\n")
)

bResult = sgsdk_SavePipeline remeshingPipeline "D:/Pipelines/Remeshing_With_Baking.json"

-- clear all pipelines
sgsdk_ClearPipelines()

# Clipping geometries

To use a clipping geometry when doing Remeshing two selection sets needs to be created. The first set is the "ProcessSelectionSet" which includes all meshes in the scene that should be processed, the second set is the "ClippingSelectionSet" which includes meshes that should be used as clipping geometries. The clipping selection set will clip everything that intersects with the clipping geometry and remove triangles that are in the negative normal direction of the surface.

Selection sets: Selection sets

Python

from pymxs import runtime as rt

# load a remeshing pipeline
remeshingPipeline = rt.sgsdk_LoadPipeline('D:/Pipelines/remeshingPipelineWithBaking.json')

# set the process selection set
bResult = rt.sgsdk_SetSetting(remeshingPipeline, 'RemeshingProcessor/RemeshingSettings/ProcessSelectionSetName', 'ProcessSelectionSet')

# set the clipping selection set
bResult = rt.sgsdk_SetSetting(remeshingPipeline, 'RemeshingProcessor/RemeshingSettings/ClippingGeometrySelectionSetName', 'ClippingSelectionSet')

# pass the settings object to the Simplygon function
bResult = rt.RunPipelineOnSelection(remeshingPipeline)

Resulting mesh:

Clipped geometry