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