Mental Ray 3.9 & Production Shaders


#26

Thanks bitter but I get an error when I try to open the scene:

// Warning: This file is from an older version of Maya. If saved, it will not be readable by previous versions. // // Error: Error reading file. //

/rachid


#27

Hmm, I don’t get the error part. It is from Maya 2011 (userdata shaders can be used in mental ray 3.8) Should be fine in 2012, it opens for me. Should be 2 planes in it.

I uploaded a different one from Maya 2012, try that.


#28

achoury, thanks for mi file, now i have this shaders eaven in hypershade.

I open file “userdata_textureMB.mb” in 2012 but some connection seems to be lost.
Maya 2011 crashes while try to open it.

Also i have warnings during maya startup

Warning: (Mayatomr.Nodes) : Node "mib_data_bool" has no ID,
assigning a temporary ID. Scene should be saved as .ma (ASCII). //  etc

Should i do something with it?

I’ll try to create network by mysefl, as described in maya help, still hope it will work.


#29

Yes I get the same error all the connections are lost for some compatibility reason!
but if you open the ASCII scene you can see how the connection are made, in fact it’s very simple
Create 02 planes, with lambert assigned to the 02 objects and execute the line code in the script editor


  addAttr -ln "miData" -at message pPlane1; createNode mib_data_shader_array -n "mib_data_shader_array1";
   setAttr -type "string" mib_data_shader_array1.names[0] "diffuse_texture";
   connectAttr -f mib_data_shader_array1.message pPlane1.miData;
    addAttr -ln "miData" -at message pPlane2;
   createNode mib_data_shader_array -n "mib_data_shader_array2";
   setAttr -type "string" mib_data_shader_array2.names[0] "diffuse_texture";
   connectAttr -f mib_data_shader_array2.message pPlane2.miData;
    createNode multiplyDivide -n "multiplyDivide1";
   createNode multiplyDivide -n "multiplyDivide2";
   createNode multiplyDivide -n "multiplyDivide3";
    createNode mib_data_get_shader_color -n "mib_data_get_shader_color1";
   connectAttr -f multiplyDivide3.message mib_data_get_shader_color1.default;
    connectAttr -f multiplyDivide1.message mib_data_shader_array1.values[0];
   connectAttr -f multiplyDivide2.message mib_data_shader_array2.values[0];
  connectAttr -force mib_data_get_shader_color1.outValue lambert1.color;
  

For the warning ID just ignore it are you can assign a random ID for each
Note: you can insert “version 1” before each “end declare” in the userdata.mi


 declare data
    .......
 	(
 	   ........
 	   .........
 	)
 	version 1
 end declare

best regards
/Rachid


#30

Thanks, Rachid, executing your code helps to investigate some connections!
And then i`m even was sucsesfull to obey this stuff works.
But for now i’m prety far from understanding whats going on and how to setup a bit different tasks:)

Scene from 2012.


#31

Forgot to mention that you have to connect the textures also


 connectAttr -force file1.outColor multiplyDivide1.input1;
connectAttr -force file2.outColor multiplyDivide1.input1;
  connectAttr -force file3.outColor multiplyDivide1.input1;

maybe someone else that has enough info about theses specific shaders can give us a little bit of “first step”
/Rachid


#32

Forgot to mention that you have to connect the textures also

It was not so difficult to understand :slight_smile:
What make me scare for now is how to understand what nodes i need for other tasks(or for what tasks i can use other user data nodes). And creating mel for this stuff.
User data tips.


#33

Think about it in this way: The command in mel “setAttr” work in general with “getAttr” right!
Approximately the same thing with “userdata”
There are: user Data Block ( all the node that you “set”)
and User Data Shaders(all the node that you “get”)
ie:
mib_data_get_bool=== work===with mib_data_bool
mib_data_get_int==== work=== mib_data_int
mib_data_get_scalar== work=== with mib_data_scalar
on so on…
/Rachid


#34

This setup is much easier with a script to generate the dynamic attribute. Afraid I don’t have one I can currently share but hopefully in the future.

If you managed to get the test file working you can see how each plane calls a different texture based on its own attribute and not the shader itself. In a larger picture you can see how different attributes can be controlled by assigning one to an object or set of instances and then using the “get_data” equivalent somewhere else.

You can now differentiate objects and duplicate instances at the object/instance level and not using a ton of shaders. A script to do this would further simplify this with a lot of objects.


#35

Ok, with this particular task everything is clear for now.

I have another task and now i cant imagine how to achieve result. For example, in PRMan reading object attributes in shader implemented in more intuitive way, thats why im a bit confused.
The task:
I have an image sequence(imagefile.###.tif) and i need that every object get image with certain frame number as input color.
Cube1 render with imagefile.XXX.tif, Cube2 render with imagefile.YYY.tif, etc.
Indeed the task is more complex, but i need at least starting point.
Any hint whould be nice.


#36

Ok, here is my “contribution” for now. Just check mayatomr is loaded and mr is your current render:

file -f -new;

polySphere;
polySphere;
move -r -4.341048 0.785068 3.752246 ;
polySphere;	// default sphere
move -r 4.341048 0.785068 -3.752246 ;

// add attr to the two first sphere wich will recieve custom value
addAttr -ln "miData" -at message pSphere1;
addAttr -ln "miData" -at message pSphere2;

// create three node wich output three differents colors
createNode multiplyDivide;
createNode multiplyDivide;
createNode multiplyDivide;

setAttr "multiplyDivide1.input1X" 1;	// red
setAttr "multiplyDivide1.input1Y" 0;
setAttr "multiplyDivide1.input1Z" 0;

setAttr "multiplyDivide2.input1X" 0;	// green
setAttr "multiplyDivide2.input1Y" 1;
setAttr "multiplyDivide2.input1Z" 0;

setAttr "multiplyDivide3.input1X" 0;	// blue
setAttr "multiplyDivide3.input1Y" 0;
setAttr "multiplyDivide3.input1Z" 1;


// create two mib_data_shader nodes to store custom colors in
createNode mib_data_shader;
createNode mib_data_shader;

setAttr -type "string" mib_data_shader1.name "COLOR";
setAttr -type "string" mib_data_shader2.name "COLOR";

connectAttr multiplyDivide1.output mib_data_shader1.value;
connectAttr multiplyDivide2.output mib_data_shader2.value;

// connect this two nodes to the mesh to override
connectAttr mib_data_shader1.message pSphere1.miData;
connectAttr mib_data_shader2.message pSphere2.miData;


// create the node wich "told" mr wich attr will recieve overrideds values
createNode mib_data_get_shader_color;

setAttr -type "string" mib_data_get_shader_color1.name "COLOR";

// set a default value (blue) for not overrided mesh
connectAttr multiplyDivide3.output mib_data_get_shader_color1.default;

// create a mia shader and assign it to the three spheres
mrCreateCustomNode -asShader "" mia_material_x;

select pSphere1 pSphere2 pSphere3;
hyperShade -assign mia_material_x1;

// connect the "data getter" to the attr to override
connectAttr mib_data_get_shader_color1.outValue mia_material_x1.diffuse;

Here is the result:

Hope this help! :beer:


#37

Another cool stuff I had just discover: Multi attributes for miData works:

addAttr -ln "miData" -at message -multi pSphere1;

This work! So you can define many overrides parameters by mesh.

Just another example I’ve made (launch in Maya2012 with mayatomr loaded):

file -f -new;

// create three spheres
polySphere;
polySphere;
move -r -2.341048 0.785068 1.752246 ;
polySphere;	// default sphere
move -r 2.341048 0.785068 -1.752246 ;

// place cam on sphere
setAttr "persp.translateX" 8.053;
setAttr "persp.translateY" 6.607;
setAttr "persp.translateZ" 8.083;
setAttr "persp.rotateX" -27.938;
setAttr "persp.rotateY" 45;

// add attr on the two first sphere wich will receive customs values
addAttr -ln "miData" -at message -multi pSphere1;
addAttr -ln "miData" -at message -multi pSphere2;

// create three node wich output three different colors
createNode multiplyDivide;
createNode multiplyDivide;
createNode multiplyDivide;

setAttr "multiplyDivide1.input1X" 1;	// red
setAttr "multiplyDivide1.input1Y" 0;
setAttr "multiplyDivide1.input1Z" 0;

setAttr "multiplyDivide2.input1X" 0;	// green
setAttr "multiplyDivide2.input1Y" 1;
setAttr "multiplyDivide2.input1Z" 0;

setAttr "multiplyDivide3.input1X" 0;	// blue
setAttr "multiplyDivide3.input1Y" 0;
setAttr "multiplyDivide3.input1Z" 1;



// create two mib_data_shader nodes to store custom colors in
createNode mib_data_shader;
createNode mib_data_shader;

setAttr -type "string" mib_data_shader1.name "COLOR";
setAttr -type "string" mib_data_shader2.name "COLOR";

connectAttr multiplyDivide1.output mib_data_shader1.value;
connectAttr multiplyDivide2.output mib_data_shader2.value;

// connect this two nodes to the mesh to override
connectAttr mib_data_shader1.message pSphere1.miData[0];
connectAttr mib_data_shader2.message pSphere2.miData[0];



// create two mib_data_shader nodes to store custom float value in
createNode mib_data_scalar;
createNode mib_data_scalar;

setAttr -type "string" mib_data_scalar1.name "SCALAR";
setAttr -type "string" mib_data_scalar2.name "SCALAR";

setAttr "mib_data_scalar1.value" 0.15;
setAttr "mib_data_scalar2.value" 0.25;

// connect this two nodes to the mesh to override (look, we use the second array element)
connectAttr mib_data_scalar1.message pSphere1.miData[1];
connectAttr mib_data_scalar2.message pSphere2.miData[1];


//Now, the shader

// create the node wich "told" mr wich attr will recieve overrideds colors
createNode mib_data_get_shader_color;

setAttr -type "string" mib_data_get_shader_color1.name "COLOR";

// set a default value (blue) for not overrided mesh
connectAttr multiplyDivide3.output mib_data_get_shader_color1.default;



// create the second node wich "told" mr wich attr will recieve overrideds float values
createNode mib_data_get_scalar;

setAttr -type "string" mib_data_get_scalar1.name "SCALAR";
setAttr mib_data_get_scalar1.default 0;



// create a mia shader and assign it to the three spheres
mrCreateCustomNode -asShader "" mia_material_x;

select pSphere1 pSphere2 pSphere3;
hyperShade -assign mia_material_x1;

// set aniso at 0.1 to see the override effect
setAttr "mia_material_x1.anisotropy" 0.1;

// connect the "data getters" to the attributes to override
connectAttr mib_data_get_shader_color1.outValue mia_material_x1.diffuse;
connectAttr mib_data_get_scalar1.outValue mia_material_x1.anisotropy_rotation;

Look the aniso rotation. :slight_smile:

Hope this help! :bounce:


#38

Nice tip, Narann, thanks!
I have strange result of aplying “-multi” flag- miData ia not visible in extra attributes in AE, but scince i have acces to this attribute from connection editor or via mel -its not a problem:)


#39

I have many probs with connection editor in 2012.

The only way I alway use to handle multi attr is script:

Find the first empty element in the list and put the connection in.


#40

hey all, quick question. Would there be any way to apply the custom miData attribute to instances created with the particle instancer?


#41

Video of the User Data Shader:

http://www.youtube.com/watch?v=KeMmr_zAcV8


#42

That vid uses the script Brenton created from the ARC forum.

Found here: Production Rendering


#43

I have a problem with the user data shaders.
I have about 800 binaryproxy cubes in my scene and each cube has a mib_data_shader assigned to its miData[0] slot.
In each mib_data_shader the name is “userdata” and a multiplyDivide node with a file node is connected.

Then I have a surface shader with a mib_data_get_shader in the color with name = “userdata”, I left the default slot empty.

But all the proxies are just black like the data_get_shader node wouldn’t find the data_shader nodes?

What did I wrong? I watched Brenton’s video, I read quite a few topics about this and I managed to get it work in a whole new test scene with just a few cubes and choosing “Color” but it seems that the file node method doesn’t work? It’s always black…

edit: But it seems that the mentalrayTexture method works. But I’d like to have file nodes :argh:


#44

I don’t think Brenton has a video. . .

I’ll check and see. We are putting out a couple fires. In the meantime have you posted this on the ARC forum? Brenton originated the script but someone else takes care of it now.


#45

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.