MEL for changing multiple shader values


i’ve searched the archives for this but drew a blank - i only know the basic MEL commands to control shader attributes individually, not all together. selecting a bunch of shaders and changing the values in the channel box doesn’t work because that will only change shaders of 1 type (blinn or lambert etc, whichever is selected last i think). and that also doesn’t work with non-keyable attributes.

basically i want to control the “miIrradianceColor” attribute on all materials in the scene. the problem is by default its a non-keyable attrbute, so i need MEL to first unlock it and then set the RGB values.

its pretty lame that maya hasn’t had some sort of global shader control gui built-in since version 1… it would be such a useful feature.

any help on this would be greatly appreciated.


this will set the “miIrradianceColor” on all the selected shaders that have that attribute.

Just change the red, green, and blue variables to the values you want. Select the shaders you want to affect, and run this in the script editor.

  	//change these to the RGB values you want
  	float $red = 0.35;
  	float $green = 0.5;
  	float $blue = 0.75;
  	string $sel[] = `ls -sl`;
  	for($i = 0;$i < size($sel);$i++)
  		if(`attributeExists miIrradianceColor $sel[$i]`)
      		setAttr ($sel[$i] + ".miIrradianceColor") -type double3 $red $green $blue;

Any questions, just ask.




a neat script - thanks heaps dude :slight_smile:


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.