Complex UV Layout in Maya
Over the last couple of years UV layout in Maya has changed for the better. In this course we're going to be taking a look at some of those changes as we UV map an entire character
# 1 06-08-2012 , 12:14 AM
Registered User
Join Date: May 2010
Posts: 14

Color Switching

Hello,

I'm trying to write an expression that exchanges a red light with a blue light shader. I would like it to be random. Problem is I'm very new to expressions so any help would be great.

Thanks

Itzat


Last edited by itzat; 06-08-2012 at 12:16 AM.
# 2 06-08-2012 , 02:10 AM
NextDesign's Avatar
Technical Director
Join Date: Feb 2004
Posts: 2,988
Hi Itzat, it would be simpler to switch the color of one shader, instead of switching between two full shaders.

One way you could do this would be to create a random number, and if it's greater than a certain value, turn green, and less than that value, turn red.

Code:
float $value = rand(0, 100);

if ($value >= 50)
    setAttr "material.color" -type double3 1 0 0 ;
else
    setAttr "material.color" -type double3 0 1 0 ;


Imagination is more important than knowledge.
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off