Just for context, I found a solution over here:
string $replaceType = "lambert";
// List all Redshift materials and Redshift Material Blender nodes in the scene
string $allRedshiftMaterials[] = `ls -type "RedshiftMaterial"`;
string $allRedshiftBlenders[] = `ls -type "RedshiftMaterialBlender"`;
string $allMaterials[];
// Concatenate the two arrays
for ($mat in $allRedshiftMaterials) {
$allMaterials[size($allMaterials)] = $mat;
}
for ($blend in $allRedshiftBlenders) {
$allMaterials[size($allMaterials)] = $blend;
}
for ($material in $allMaterials) {
// Get the connected shading engines for each material
string $shadingEngines[] = `listConnections -type "shadingEngine" ($material + ".outColor")`;
for ($each in $shadingEngines) {
// Create a new Lambert material
string $newMaterial = `shadingNode -asShader $replaceType`;
// Determine the appropriate attribute for base color
string $attr = "diffuse_color";
if (`nodeType $material` == "RedshiftMaterialBlender") {
$attr = "baseColor";
}
if (`attributeExists $attr $material`) {
string $connections[] = `listConnections ($material + "." + $attr)`;
if (size($connections) > 0) {
string $sourceAttr = $connections[0] + ".outColor";
if (`attributeExists "outColor" $connections[0]`) {
// Connect the source attribute to the new Lambert material
connectAttr -f $sourceAttr ($newMaterial + ".color");
} else {
warning("Unsupported connection type for material: " + $material);
}
} else {
// Copy the base color from the Redshift material to the Lambert's color
float $baseColor[] = `getAttr ($material + "." + $attr)`;
setAttr ($newMaterial + ".color") $baseColor[0] $baseColor[1] $baseColor[2];
}
} else {
warning("Attribute " + $attr + " does not exist for material: " + $material);
}
// Transfer the name from old material to new one
string $newMaterialName = $material + "_lambert";
$newMaterial = `rename $newMaterial $newMaterialName`;
// Disconnect existing connection from shading engine, if any
string $existingConnection[] = `listConnections -plugs true ($each + ".surfaceShader")`;
if (size($existingConnection) > 0) {
disconnectAttr $existingConnection[0] ($each + ".surfaceShader");
}
// Connect the new Lambert material to the shading engine
connectAttr -f ($newMaterial + ".outColor") ($each + ".surfaceShader");
// Delete the old Redshift material
delete $material;
}
}