# 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.
// create a Remeshing Pipeline 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)
$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/RemeshingV2_With_Baking.json" $remeshingPipeline`;
}
else
{
$bResult = `SimplygonPipeline -s "D:/Pipelines/RemeshingV2.json" $remeshingPipeline`;
}
// clear all pipelines
SimplygonPipeline -cl;