|06 June 2007||#1|
Felipe Cartin Arteaga
San Jose, Costa Rica
Changing Materials throught a Ctrl
Well, ive been workin on a rig for a character of mine, and i wanted to be able to change the entire shader of a couple of objects with just switching "on" or "off" on an attribute on a controller object. For example:
if (Ctrl.Shader = 1)
object1.shader = dilectricshapenode
object1.shader = blinn1;
For example. *i know the code doesnt make sense, lol, just for reference*
Ive been watching the script editor when i assign a shader to an object, but the code there doesnt seem to work on the Expression editor... any ideas?
|10 October 2007||#3|
Electronic Arts Canada
Join Date: Jul 2002
If you're not using a GUI, you're going to have to use a scriptJob in combination with mel scripts. **Edit: Make sure you read the docs on scriptJobs, they can be dangerous.
And in your procedure, just do an if/else statement querying the value of mySphere.customAttribute
Last edited by Norb : 10 October 2007 at 04:55 PM.
|10 October 2007||#4|
yep the script job is the way to go.
as well, another way would be to plug all the shaders through a layered shader
and use the driven key to switch the layerOpacity based on your ctrl.shader
|10 October 2007||#5|
As Norb already pointed out, you could also use a simple GUI for this.
Something like this:
window -h 30 -w 40;
checkBox -label "Toggle material"
-cc "if (`checkBox -q -v checkbox1`==0) hyperShade -assign matBlue; else hyperShade -assign matGreen;" checkbox1;
|10 October 2007||#6|
Join Date: Sep 2003
Thread automatically closed
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.
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
|Thread Closed share thread|