# Simple Remeshing pipeline (legacy remesher)
This example shows how to create a new RemeshingLegacyPipeline
and how to set basic parameters for Remeshing and material baking.
// create a Remeshing Pipeline object
$remeshingPipeline = `SimplygonPipeline -c "RemeshingLegacyPipeline"`;
// 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 "RemeshingLegacyProcessor/RemeshingLegacySettings/OnScreenSize" -v 300 $remeshingPipeline`;
$onScreenSize = `SimplygonPipeline -gs "RemeshingLegacyProcessor/RemeshingLegacySettings/OnScreenSize" $remeshingPipeline`;
print ("OnScreenSize: " + $onScreenSize + "\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 = `SimplygonPipeline -ss "RemeshingLegacyProcessor/RemeshingLegacySettings/MergeDistance" -v 0 $remeshingPipeline`;
$mergeDistance = `SimplygonPipeline -gs "RemeshingLegacyProcessor/RemeshingLegacySettings/MergeDistance" $remeshingPipeline`;
print ("MergeDistance: " + $mergeDistance + "\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 "RemeshingLegacyProcessor/MappingImageSettings/GenerateMappingImage" -v true $remeshingPipeline`;
$generateMappingImage = `SimplygonPipeline -gs "RemeshingLegacyProcessor/MappingImageSettings/GenerateMappingImage" $remeshingPipeline`;
print ("GenerateMappingImage: " + $generateMappingImage + "\n");
// in this case we want to generate texture coordinates (UVs)
$bResult = `SimplygonPipeline -ss "RemeshingLegacyProcessor/MappingImageSettings/GenerateTexCoords" -v true $remeshingPipeline`;
$generateTexCoords = `SimplygonPipeline -gs "RemeshingLegacyProcessor/MappingImageSettings/GenerateTexCoords" $remeshingPipeline`;
print ("GenerateTexCoords: " + $generateTexCoords + "\n");
// the name of the resulting texture coordinate field
$bResult = `SimplygonPipeline -ss "RemeshingLegacyProcessor/MappingImageSettings/TexCoordName" -v "MaterialLOD" $remeshingPipeline`;
$texCoordLevel = `SimplygonPipeline -gs "RemeshingLegacyProcessor/MappingImageSettings/TexCoordName" $remeshingPipeline`;
print ("TexCoordName: " + $texCoordLevel + "\n");
// width of the baked textures
$bResult = `SimplygonPipeline -ss "RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureWidth" -v 512 $remeshingPipeline`;
$textureWidth = `SimplygonPipeline -gs "RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureWidth" $remeshingPipeline`;
print ("TextureWidth: " + $textureWidth + "\n");
// height of the baked textures
$bResult = `SimplygonPipeline -ss "RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureHeight" -v 512 $remeshingPipeline`;
$textureHeight = `SimplygonPipeline -gs "RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureHeight" $remeshingPipeline`;
print ("TextureHeight: " + $textureHeight + "\n");
// add material casters (ambientColor, color, specularColor and normalCamera)
$bCasterAdded = `SimplygonPipeline -amc "ColorCaster" $remeshingPipeline`;
$bResult = `SimplygonPipeline -ss "MaterialCaster/0/ColorCasterSettings/MaterialChannel" -v "ambientColor" $remeshingPipeline`;
$colorCaster0 = `SimplygonPipeline -gs "MaterialCaster/0/ColorCasterSettings/MaterialChannel" $remeshingPipeline`;
print ("ColorCaster0: " + $colorCaster0 + "\n");
$bCasterAdded = `SimplygonPipeline -amc "ColorCaster" $remeshingPipeline`;
$bResult = `SimplygonPipeline -ss "MaterialCaster/1/ColorCasterSettings/MaterialChannel" -v "color" $remeshingPipeline`;
$colorCaster1 = `SimplygonPipeline -gs "MaterialCaster/1/ColorCasterSettings/MaterialChannel" $remeshingPipeline`;
print ("ColorCaster1: " + $colorCaster1 + "\n");
$bCasterAdded = `SimplygonPipeline -amc "ColorCaster" $remeshingPipeline`;
$bResult = `SimplygonPipeline -ss "MaterialCaster/2/ColorCasterSettings/MaterialChannel" -v "specularColor" $remeshingPipeline`;
$colorCaster2 = `SimplygonPipeline -gs "MaterialCaster/2/ColorCasterSettings/MaterialChannel" $remeshingPipeline`;
print ("ColorCaster2: " + $colorCaster2 + "\n");
// note: normal caster for normals!
$bCasterAdded = `SimplygonPipeline -amc "NormalCaster" $remeshingPipeline`;
$bResult = `SimplygonPipeline -ss "MaterialCaster/3/NormalCasterSettings/MaterialChannel" -v "normalCamera" $remeshingPipeline`;
$normalCaster3 = `SimplygonPipeline -gs "MaterialCaster/3/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/3/NormalCasterSettings/GenerateTangentSpaceNormals" -v true $remeshingPipeline`;
$generateTangentSpaceNormals = `SimplygonPipeline -gs "MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals" $remeshingPipeline`;
print ("GenerateTangentSpaceNormals: " + $generateTangentSpaceNormals + "\n");
}
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;
import maya.cmds as cmds
# create a Remeshing Pipeline object
remeshingPipeline = cmds.SimplygonPipeline(c = 'RemeshingLegacyPipeline')
# 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 = 'RemeshingLegacyProcessor/RemeshingLegacySettings/OnScreenSize', v = 300)
onScreenSize = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingLegacyProcessor/RemeshingLegacySettings/OnScreenSize')
print ('OnScreenSize: ' + str(onScreenSize) + '\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 = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingLegacyProcessor/RemeshingLegacySettings/MergeDistance', v = 0)
mergeDistance = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingLegacyProcessor/RemeshingLegacySettings/MergeDistance')
print ('MergeDistance: ' + str(mergeDistance) + '\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 = 'RemeshingLegacyProcessor/MappingImageSettings/GenerateMappingImage', v = True)
generateMappingImage = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingLegacyProcessor/MappingImageSettings/GenerateMappingImage')
print ('GenerateMappingImage: ' + str(generateMappingImage) + '\n')
# in this case we want to generate texture coordinates (UVs)
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingLegacyProcessor/MappingImageSettings/GenerateTexCoords', v = True)
generateTexCoords = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingLegacyProcessor/MappingImageSettings/GenerateTexCoords')
print ('GenerateTexCoords: ' + str(generateTexCoords) + '\n')
# the name of the resulting texture coordinate field
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingLegacyProcessor/MappingImageSettings/TexCoordName', v = 'MaterialLOD')
texCoordLevel = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingLegacyProcessor/MappingImageSettings/TexCoordName')
print ('TexCoordName: ' + texCoordLevel + '\n')
# width of the baked textures
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureWidth', v = 512)
textureWidth = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureWidth')
print ('TextureWidth: ' + str(textureWidth) + '\n')
# height of the baked textures
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureHeight', v = 512)
textureHeight = cmds.SimplygonPipeline(remeshingPipeline, gs = 'RemeshingLegacyProcessor/MappingImageSettings/Output0/TextureHeight')
print ('TextureHeight: ' + str(textureHeight) + '\n')
# add material casters (ambientColor, color, specularColor and normalCamera)
bCasterAdded = cmds.SimplygonPipeline(remeshingPipeline, amc = 'ColorCaster')
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'MaterialCaster/0/ColorCasterSettings/MaterialChannel', v = 'ambientColor')
colorCaster0 = cmds.SimplygonPipeline(remeshingPipeline, gs = 'MaterialCaster/0/ColorCasterSettings/MaterialChannel')
print ('ColorCaster0: ' + colorCaster0 + '\n')
bCasterAdded = cmds.SimplygonPipeline(remeshingPipeline, amc = 'ColorCaster')
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'MaterialCaster/1/ColorCasterSettings/MaterialChannel', v = 'color')
colorCaster1 = cmds.SimplygonPipeline(remeshingPipeline, gs = 'MaterialCaster/1/ColorCasterSettings/MaterialChannel')
print ('ColorCaster1: ' + colorCaster1 + '\n')
bCasterAdded = cmds.SimplygonPipeline(remeshingPipeline, amc = 'ColorCaster')
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'MaterialCaster/2/ColorCasterSettings/MaterialChannel', v = 'specularColor')
colorCaster2 = cmds.SimplygonPipeline(remeshingPipeline, gs = 'MaterialCaster/2/ColorCasterSettings/MaterialChannel')
print ('ColorCaster2: ' + colorCaster2 + '\n')
# note: normal caster for normals!
bCasterAdded = cmds.SimplygonPipeline(remeshingPipeline, amc = 'NormalCaster')
bResult = cmds.SimplygonPipeline(remeshingPipeline, ss = 'MaterialCaster/3/NormalCasterSettings/MaterialChannel', v = 'normalCamera')
normalCaster3 = cmds.SimplygonPipeline(remeshingPipeline, 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(remeshingPipeline, ss = 'MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals', v = True)
generateTangentSpaceNormals = cmds.SimplygonPipeline(remeshingPipeline, gs = 'MaterialCaster/3/NormalCasterSettings/GenerateTangentSpaceNormals')
print ('GenerateTangentSpaceNormals: ' + str(generateTangentSpaceNormals) + '\n')
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 Legacy Remeshing Pipeline: