PDA

View Full Version : Implicit Object Reference in MEL Shading Expression


mprater
09-27-2006, 12:23 AM
Is there a way to refer to an attribute of a surface patch without sepcifying the name of the object? I want to use the value of an attribute I've attached to nurb surface to control the shading of the surface using an expression. The scene has many nurb surfaces, each with the same named attribute attached, but each has a different value contained in the attribute. I have a single shading network to attach to all the surfaces, and I want to access the value of the attached surface attribute to control the shading of each individual nurb surface.

isoparmB
09-27-2006, 04:32 AM
Instead of using expressions:

Depending on what type of attribute you want to control on your shader network (wether it has a single input like Diffuse, double inputs like the UV coordinates in a place2dTexture, or three inputs like that of the transparency channel), you can use either a single, double or triple shading switch, and connect the attribute of each surface to it's respective input array placement in the switch.

You first assign your shader to all your objects. Then, map an appropriate shading switch node to the attribute you want to control. Let's say for example you want to control color, you'd use a triple shading switch (because color in maya consists of R, G, and B channels, or H, S, V depending on your settings). You then open the attribute editor of the switch, click on the map button so that it updates the surfaces currently assigned to the shader (This also updates the number of input array slots found in the switch). You can then either manually connect the objects to the shading switch using the object's attribute (in this case three attributes, or one attribute connected to the three inputs of each object in the shading switch), or use a for in loop to cycle through a list of objects to connect to the apporpriate shading switch input attribute (make sure this list is in the same order as found in the shading switch, though).

CGTalk Moderation
09-27-2006, 04:32 AM
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.