PDA

View Full Version : Refresh Material assignment On Instance


smoluck
10-05-2010, 04:28 AM
Hello everyone.

As you know it, Maya can get many instance of an object at one time, but let's the possibility to apply on these instanced geometry different material. It could be good for rendering purpose, but for game content creation it could be a nightmare.

As I'm currently trying to clean an old scene and reassign some updated shape to the instance i already have in that scene, i've seen that i can't refresh the material linking (as a Face level) and i can't get the instance updated if i apply to the source_Shaphe different material on it's geometry.

For exemple:
You can create a cube. Duplicate it as instanced geometry 3 times, and after if you select 2 face of the original shape in order to assign a new material on this 2 face, the instance got not updated at all.

How could I correct this ?

rahulsg2901
10-05-2010, 07:31 AM
Check out this script work for you or not
Script simply goes each face & assigns original object material

First select original object & then select instance geometry


global proc instMat ()
{
string $sel [] =`ls -sl`;
int $size = size($sel);
select -cl;
select $sel[0];
//Get all shading node of first object
hyperShade -smn;
string $mat[] =`ls -sl`;

for ($each in $mat)
{
select -cl;
hyperShade -objects $each;

string $matFace [] =`ls -sl`;

//for each shading node get assign face
for ($eachFace in $matFace)
{

for ($i=1; $i<$size; $i++)
{
//Assign material to each face
string $name = `substitute $sel[0] $eachFace $sel[$i]`;
select -cl;
select $name;
sets -e -forceElement ($each + "SG");
}
}

}
select -cl;
};

smoluck
10-11-2010, 03:59 AM
This script didn't work for me. I didn't got error message , and nothing happens. Do I need to add the proc command start ?

----------------------

On another problem, i got that message when i want to parent the instance to a group.

Look at this error message from the script editor:

// Warning: Node 'EnvGlo_SOURCE_PanneauDepassementInterditVoiture_INSTANCE.instObjGroups[0].objectGroups[3]': cannot make assignment to 'PanneauAtlas_SG' shader. //
// Error: Connection not made: 'EnvGlo_SOURCE_PanneauDepassementInterditVoiture_INSTANCE.instObjGroups[0].objectGroups[3]' -> 'PanneauAtlas_SG.dagSetMembers[0]'. Source node will not allow the connection. //

If i assign the basic lambert1 or another material on the original instance and duplicate as simple copy all the targeted instanced object (already in place) and connect the shape node to these transform, in order to convert it to instance, it doesn't fix that problem.

rahulsg2901
10-11-2010, 07:51 AM
This script didn't work for me. I didn't got error message , and nothing happens. Do I need to add the proc command start ?


Copy above script >> past in to Maya script editor (in MEL section) >> select all the script >> hit ctrl + Enter

Now first select base object that has texture on it >> shift select all the instance object >>
Go to Maya script editor type below the script instMat or select this word from script >> hit ctrl + Enter.
Thats it :shrug: :bounce:

smoluck
10-14-2010, 12:27 PM
Ho Yeah, I've fogoten that little tweak.

Did you know if it could be possible to Do that script through Material selection, instead of select the shape, as I'm always trying to connect the same node to the instance as same as the original shape.

----

Did you ever know how to reconnect a Material to it's own ShadingGroup ? .... I've some problem on my scene with the groupId. I mean why maya create 3 groupId when I just got 2 material on different face of a mesh ? some times it make's a crappy scene with a lot of unoptimized Node.

So Why do I got sometimes a ShadingGroup on the output of my Phong, and sometimes a materialInfo ? Do you got a script for a cleaning process on Material ?

rahulsg2901
10-14-2010, 04:05 PM
Did you know if it could be possible to Do that script through Material selection, instead of select the shape, as I'm always trying to connect the same node to the instance as same as the original shape.


it too complex to add this script in hypershade but you can put this in shelf. just select all script from script editor but put this line end of the script instMat; (same as mention in Red) & middle click & drag to shelf.



Did you ever know how to reconnect a Material to it's own ShadingGroup ?


put shader & shading group in to hypershade. middle click & drag from material to shading group >> click to default


I've some problem on my scene with the groupId. I mean why maya create 3 groupId when I just got 2 material on different face of a mesh ? some times it make's a crappy scene with a lot of unoptimized Node.


because every time you create a shader maya create a shading group with them if you delete some material you just delete shader not shading group that's why you get extra shading groups



So Why do I got sometimes a ShadingGroup on the output of my Phong, and sometimes a materialInfo ? Do you got a script for a cleaning process on Material ?


there is option itself in the Maya to clean unused node you find that in hypershade >> edit menu >> delete unused nodes. this option delete node that are not use in scene it work many time but some time it delete some useful node

;)

CGTalk Moderation
10-14-2010, 04:05 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.