Community
Maya Forum
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Transferring redshift material to default Maya material for Unreal import

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ddfzhh
288 Views, 2 Replies

Transferring redshift material to default Maya material for Unreal import

Software versions in this forum: Maya 2018, Redshift 3.0.45, Unreal 5.2

 

Hi guys, 

I am trying to do previs in Unreal Engine and would like to at least have a base color map on the models to give me a basic guide of what the object is. 

 

The models that I am working with right now are shaded in Redshift (redshift for Maya plugin). I wonder if there is a way to change the materials to default Maya materials (blinn or Lambert)with at least the base color (diffuse color in Redshift I think). That way I can embed the texture maps to a FBX file and import it into Unreal since Unreal only recognizes several default Maya shaders.  I want to bulk transfer it for all the materials. 

Any idea how to do this? Thanks! 

 

 

 

Labels (1)
2 REPLIES 2
Message 2 of 3
damaggio
in reply to: ddfzhh

here ....👍

 

string $replaceType = "lambert";
string $sNode[] = `ls -sl`;
for ($each in $sNode)


Message 3 of 3
ddfzhh
in reply to: ddfzhh

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Technology Administrators


Autodesk Design & Make Report