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: 

Material per UDIM

2 REPLIES 2
Reply
Message 1 of 3
eqrsr
1381 Views, 2 Replies

Material per UDIM

Hi

I'm sure this must be a very common issue in the Maya to Unreal workflow but I can't find any solution for it.

I need to migrate assets that have textures across multiple UDIMs from Maya to Unreal.
In order to read UDIMs, Unreal requires a model with different materials assigned to each UDIM, so that it can create corresponding material slots.

Is there an easy way to create a material per UDIM in Maya?

2 REPLIES 2
Message 2 of 3
eqrsr
in reply to: eqrsr

Is this really such a special case?

Message 3 of 3
allMDE9E
in reply to: eqrsr

Hey. So I saw your question and I needed the same solution, so I wrote a script. So for anyone, who needs this:

 

string $mySel[] = `ls -sl`;
string $allGeo[] = `filterExpand -sm 12 $mySel[0]`;

if (size($allGeo) > 1){
    string $newPoly[] = `polyUnite -ch 1 -mergeUVSets 2 -centerPivot -name $allGeo`;
    select -r $newPoly[0];
    select -add $mySel[0];
    parent;
    select -r $newPoly[0];
    DeleteHistory;
}

float $uNums,$vNums;
int $UVNum = 20;
for($u = 0; $u < $UVNum; $u++){

    for($v = 0; $v < $UVNum; $v++){
        print($u + "  " + $v + "\n");
        $uNums = $u;
        $vNums = $v;
        float $uPoint = $uNums + 0.5;
        float $vPoint = $vNums + 0.5;
        polySelectConstraint -m 3 -t 0x0010 -d 1 -dp $uPoint $vPoint 0 -db 0 0.75;
        string $preProcessSel[] = `ls -sl -fl`; 
        polySelectConstraint -m 0 -t 0x0010 -d 0 -dp 0 0 0 -db 0 0;
        resetPolySelectConstraint;
        if (size($preProcessSel) > 0){
            float $minU = $uNums;
            float $minV = $vNums; 
            float $maxU = $uNums + 1;
            float $maxV = $vNums + 1;
            
            string $finalSelection[];
            int $counter=0;
            for($thisFace in $preProcessSel){
                float $tempUVs[] = `polyEditUV -q -u -v $thisFace`;
                
                if(($tempUVs[0] < $maxU && $tempUVs[0] > $minU )&&($tempUVs[1] < $maxV && $tempUVs[1] > $minV )){
                    //print($minU + "  " + $maxU + "  " + $minV + "  " + $maxV + "  " + $tempUVs[0] + "  " + $tempUVs[1] + "\n");
                    $finalSelection[$counter] = $thisFace;
                    $counter++;
                }
            }
            
            if (size($finalSelection) > 0){
                select -replace $finalSelection;
                PolySelectConvert 1;
                string $currentSelection[] = `ls -sl`;
                             
                string $newMtl=`shadingNode -as -n ("UDIM_10"+$v+($u+1)) blinn`;
                string $newSG=`sets -renderable true -noSurfaceShader true -empty -name ( $newMtl + "SG" )`;
                
                print($newMtl + "\n");
                print($newSG + "\n");
                print( $currentSelection);
                
                connectAttr -f ( $newMtl + ".outColor" ) ( $newSG + ".surfaceShader" );
                
                for ($thisSelection in $currentSelection){
                    select -r $thisSelection;
                    sets -e -forceElement $newSG;
                }

            }
            clear $finalSelection;
        }
    }
   
}

The first part is merging the geo first. If you dont need that, than skip that step. Also the naming of the UDIM materials are only correct for 1001-1009 after that I couldnt be bothered to check for correct naming. You might need to fix that or do it manually, as I am right now.

 

Hope that helps you or anyone, who is searching for this. 

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

Post to forums