PDA

View Full Version : one shader many object colors??


altruizine
03-01-2005, 04:39 PM
Hi, Does anyone know if it is possible to create a shader that looks at it's host object for a color attribute and renders that color?

For example if I have 50 boxes that I want to render each as a different color and each box has a custom attribute called "color" can I create one shader that can read in that attribute for each box?

-JF

Hirni_NG
03-01-2005, 10:38 PM
Of course you can, here is a way to do it:

-select all your objects, then enter in the script editor

addAttr -longName myColor -usedAsColor -attributeType float3;
addAttr -longName myRed -attributeType "float" -parent myColor;
addAttr -longName myGreen -attributeType "float" -parent myColor;
addAttr -longName myBlue -attributeType "float" -parent myColor;

This will add a color attribute to every object (not the shape node but the transform node). Open the Extra Atrributes and you will hopefully see the new myColor attribute.

Now in Hypershade create a tripleShadingSwitch and connect the output to whatever color you want to map in your shader.

Open the Attribute Editor of the tripleShadingSwitch and enter the name of each object
in the inShape table. (This is quite tedious and can be done with a script too but it is probably faster to cut and paste names for only 50 objects.)

In the inTriple column, enter each corresponding object name with a .myColor
so the table looks like this for example:

nurbsSphere1 nurbsSphere1.myColor
nurbsSphere2 nurbsSphere2.myColor
nurbsSphere3 nurbsSphere3.myColor
... ...

Now you can edit the colors of each object with the myColor attribute.
You cannot map the extra myColor attribute to a texture though but you can
render in MR, too.

CGTalk Moderation
03-01-2006, 11:00 PM
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.