Skip to content
On this page

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.

MEL
// create a RemeshingPipeline object
$remeshingPipeline = `SimplygonPipeline -c "RemeshingPipeline"`;

// set DefaultTangentCalculatorType to OrthonormalRightHanded (0)
$bResult = `SimplygonPipeline -ss "GlobalSettings/DefaultTangentCalculatorType" -v 0 $remeshingPipeline`;
$defaultTangentCalculatorType = `SimplygonPipeline -gs "GlobalSettings/DefaultTangentCalculatorType" $remeshingPipeline`;
print ("DefaultTangentCalculatorType: " + $defaultTangentCalculatorType + "\n");

// set the OnScreenSize for the generated mesh
$bResult = `SimplygonPipeline -ss "RemeshingProcessor/RemeshingSettings/OnScreenSize" -v 300 $remeshingPipeline`;
$onScreenSize = `SimplygonPipeline -gs "RemeshingProcessor/RemeshingSettings/OnScreenSize" $remeshingPipeline`;
print ("OnScreenSize: " + $onScreenSize + "\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 = `SimplygonPipeline -ss "RemeshingProcessor/RemeshingSettings/HoleFilling" -v 1 $remeshingPipeline`;
$holeFilling = `SimplygonPipeline -gs "RemeshingProcessor/RemeshingSettings/HoleFilling" $remeshingPipeline`;
print ("HoleFilling: " + $holeFilling + "\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)
{
    // enable material baking
    // mapping image is required for material baking
    $bResult = `SimplygonPipeline -ss "RemeshingProcessor/MappingImageSettings/GenerateMappingImage" -v true $remeshingPipeline`;
    $generateMappingImage = `SimplygonPipeline -gs "RemeshingProcessor/MappingImageSettings/GenerateMappingImage" $remeshingPipeline`;
    print ("GenerateMappingImage: " + $generateMappingImage + "\n");

    // in this case we want to generate texture coordinates (UVs)
    $bResult = `SimplygonPipeline -ss "RemeshingProcessor/MappingImageSettings/GenerateTexCoords" -v true $remeshingPipeline`;
    $generateTexCoords = `SimplygonPipeline -gs "RemeshingProcessor/MappingImageSettings/GenerateTexCoords" $remeshingPipeline`;
    print ("GenerateTexCoords: " + $generateTexCoords + "\n");

    // the name of the resulting texture coordinate field
    $bResult = `SimplygonPipeline -ss "RemeshingProcessor/MappingImageSettings/TexCoordName" -v "MaterialLOD" $remeshingPipeline`;
    $texCoordLevel = `SimplygonPipeline -gs "RemeshingProcessor/MappingImageSettings/TexCoordName" $remeshingPipeline`;
    print ("TexCoordName: " + $texCoordLevel + "\n");

    // width of the baked textures
    $bResult = `SimplygonPipeline -ss "RemeshingProcessor/MappingImageSettings/Output0/TextureWidth" -v 512 $remeshingPipeline`;
    $textureWidth = `SimplygonPipeline -gs "RemeshingProcessor/MappingImageSettings/Output0/TextureWidth" $remeshingPipeline`;
    print ("TextureWidth: " + $textureWidth + "\n");

    // height of the baked textures
    $bResult = `SimplygonPipeline -ss "RemeshingProcessor/MappingImageSettings/Output0/TextureHeight" -v 512 $remeshingPipeline`;
    $textureHeight = `SimplygonPipeline -gs "RemeshingProcessor/MappingImageSettings/Output0/TextureHeight" $remeshingPipeline`;
    print ("TextureHeight: " + $textureHeight + "\n");

    // add material casters (ambientColor, color, specularColor and normalCamera)
    $casterIndex = `SimplygonPipeline -amc "ColorCaster" $remeshingPipeline`;
    $bResult = `SimplygonPipeline -ss ("MaterialCaster/" + $casterIndex + "/ColorCasterSettings/MaterialChannel") -v "ambientColor" $remeshingPipeline`;
    $colorCaster0 = `SimplygonPipeline -gs ("MaterialCaster/" + $casterIndex + "/ColorCasterSettings/MaterialChannel") $remeshingPipeline`;
    print ("ColorCaster0: " + $colorCaster0 + "\n");

    $casterIndex = `SimplygonPipeline -amc "ColorCaster" $remeshingPipeline`;
    $bResult = `SimplygonPipeline -ss ("MaterialCaster/" + $casterIndex + "/ColorCasterSettings/MaterialChannel") -v "color" $remeshingPipeline`;
    $colorCaster1 = `SimplygonPipeline -gs ("MaterialCaster/" + $casterIndex + "/ColorCasterSettings/MaterialChannel") $remeshingPipeline`;
    print ("ColorCaster1: " + $colorCaster1 + "\n");

    $casterIndex = `SimplygonPipeline -amc "ColorCaster" $remeshingPipeline`;
    $bResult = `SimplygonPipeline -ss ("MaterialCaster/" + $casterIndex + "/ColorCasterSettings/MaterialChannel") -v "specularColor" $remeshingPipeline`;
    $colorCaster2 = `SimplygonPipeline -gs ("MaterialCaster/" + $casterIndex + "/ColorCasterSettings/MaterialChannel") $remeshingPipeline`;
    print ("ColorCaster2: " + $colorCaster2 + "\n");

    // note: normal caster for normals!
    $casterIndex = `SimplygonPipeline -amc "NormalCaster" $remeshingPipeline`;
    $bResult = `SimplygonPipeline -ss ("MaterialCaster/" + $casterIndex + "/NormalCasterSettings/MaterialChannel") -v "normalCamera" $remeshingPipeline`;
    $normalCaster3 = `SimplygonPipeline -gs ("MaterialCaster/" + $casterIndex + "/NormalCasterSettings/MaterialChannel") $remeshingPipeline`;
    print ("NormalCaster3: " + $normalCaster3 + "\n");

    // set the correct tangent space type,
    // in this example we use tangent space normals
    $bResult = `SimplygonPipeline -ss ("MaterialCaster/" + $casterIndex + "/NormalCasterSettings/GenerateTangentSpaceNormals") -v true $remeshingPipeline`;
    $generateTangentSpaceNormals = `SimplygonPipeline -gs ("MaterialCaster/" + $casterIndex + "/NormalCasterSettings/GenerateTangentSpaceNormals") $remeshingPipeline`;
    print ("GenerateTangentSpaceNormals: " + $generateTangentSpaceNormals + "\n");
}

// save the generated Pipeline object to file for later use
if($bMaterialBake)
{
    $bResult = `SimplygonPipeline -s "D:/Pipelines/Remeshing_With_Baking.json" $remeshingPipeline`;  
}
else
{
    $bResult = `SimplygonPipeline -s "D:/Pipelines/Remeshing.json" $remeshingPipeline`;
}

// clear all pipelines
SimplygonPipeline -cl;
python
import maya.cmds as cmds

# create a RemeshingPipeline object
remeshingPipeline = cmds.SimplygonPipeline(c = 'RemeshingPipeline')

# set DefaultTangentCalculatorType to OrthonormalRightHanded (0)
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'GlobalSettings/DefaultTangentCalculatorType', v = 0)
defaultTangentCalculatorType = cmds.SimplygonPipeline(remeshingPipeline, gs = 'GlobalSettings/DefaultTangentCalculatorType')
print ('DefaultTangentCalculatorType: ' + str(defaultTangentCalculatorType) + '\n')

# set the OnScreenSize for the generated mesh
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingProcessor/RemeshingSettings/OnScreenSize', v = 300)
onScreenSize = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingProcessor/RemeshingSettings/OnScreenSize')
print ('OnScreenSize: ' + str(onScreenSize) + '\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 = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingProcessor/RemeshingSettings/HoleFilling', v = 1)
holeFilling = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingProcessor/RemeshingSettings/HoleFilling')
print ('HoleFilling: ' + str(holeFilling) + '\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:
    # enable material baking
    # mapping image is required for material baking
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingProcessor/MappingImageSettings/GenerateMappingImage', v = True)
    generateMappingImage = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingProcessor/MappingImageSettings/GenerateMappingImage')
    print ('GenerateMappingImage: ' + str(generateMappingImage) + '\n')

    # in this case we want to generate texture coordinates (UVs)
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingProcessor/MappingImageSettings/GenerateTexCoords', v = True)
    generateTexCoords = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingProcessor/MappingImageSettings/GenerateTexCoords')
    print ('GenerateTexCoords: ' + str(generateTexCoords) + '\n')

    # the name of the resulting texture coordinate field
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingProcessor/MappingImageSettings/TexCoordName', v = 'MaterialLOD')
    texCoordLevel = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingProcessor/MappingImageSettings/TexCoordName')
    print ('TexCoordName: ' + texCoordLevel + '\n')

    # width of the baked textures
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingProcessor/MappingImageSettings/Output0/TextureWidth', v = 512)
    textureWidth = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingProcessor/MappingImageSettings/Output0/TextureWidth')
    print ('TextureWidth: ' + str(textureWidth) + '\n')

    # height of the baked textures
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingProcessor/MappingImageSettings/Output0/TextureHeight', v = 512)
    textureHeight = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingProcessor/MappingImageSettings/Output0/TextureHeight')
    print ('TextureHeight: ' + str(textureHeight) + '\n')

    # add material casters (ambientColor, color, specularColor and normalCamera)
    casterIndex = cmds.SimplygonPipeline(remeshingPipeline, amc = 'ColorCaster')
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = ('MaterialCaster/' + str(casterIndex) + '/ColorCasterSettings/MaterialChannel'), v = 'ambientColor')
    colorCaster0 = cmds.SimplygonPipeline(remeshingPipeline, gs = ('MaterialCaster/' + str(casterIndex) + '/ColorCasterSettings/MaterialChannel'))
    print ('ColorCaster0: ' + colorCaster0 + '\n')

    casterIndex = cmds.SimplygonPipeline(remeshingPipeline, amc = 'ColorCaster')
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = ('MaterialCaster/' + str(casterIndex) + '/ColorCasterSettings/MaterialChannel'), v = 'color')
    colorCaster1 = cmds.SimplygonPipeline(remeshingPipeline, gs = ('MaterialCaster/' + str(casterIndex) + '/ColorCasterSettings/MaterialChannel'))
    print ('ColorCaster1: ' + colorCaster1 + '\n')

    casterIndex = cmds.SimplygonPipeline(remeshingPipeline, amc = 'ColorCaster')
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = ('MaterialCaster/' + str(casterIndex) + '/ColorCasterSettings/MaterialChannel'), v = 'specularColor')
    colorCaster2 = cmds.SimplygonPipeline(remeshingPipeline, gs = ('MaterialCaster/' + str(casterIndex) + '/ColorCasterSettings/MaterialChannel'))
    print ('ColorCaster2: ' + colorCaster2 + '\n')

    # note: normal caster for normals!
    casterIndex = cmds.SimplygonPipeline(remeshingPipeline, amc = 'NormalCaster')
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = ('MaterialCaster/' + str(casterIndex) + '/NormalCasterSettings/MaterialChannel'), v = 'normalCamera')
    normalCaster3 = cmds.SimplygonPipeline(remeshingPipeline, gs = ('MaterialCaster/' + str(casterIndex) + '/NormalCasterSettings/MaterialChannel'))
    print ('NormalCaster3: ' + normalCaster3 + '\n')

    # set the correct tangent space type,
    # in this example we use tangent space normals
    bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = ('MaterialCaster/' + str(casterIndex) + '/NormalCasterSettings/GenerateTangentSpaceNormals'), v = True)
    generateTangentSpaceNormals = cmds.SimplygonPipeline(remeshingPipeline, gs = ('MaterialCaster/' + str(casterIndex) + '/NormalCasterSettings/GenerateTangentSpaceNormals'))
    print ('GenerateTangentSpaceNormals: ' + str(generateTangentSpaceNormals) + '\n')

# save the generated Pipeline object to file for later use
if bMaterialBake:
    bResult = cmds.SimplygonPipeline(remeshingPipeline, s = 'D:/Pipelines/Remeshing_With_Baking.json')  
else:
    bResult = cmds.SimplygonPipeline(remeshingPipeline, s = 'D:/Pipelines/Remeshing.json')

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

Next steps

Get to know how to use the Remeshing Pipeline: