Community
Arnold for 3ds Max
Rendering with Arnold in 3ds Max using the MaxtoA plug-in.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I feed an object ID value into a shader?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
J-Fry
1068 Views, 2 Replies

How do I feed an object ID value into a shader?

Hi everybody! I am using Maya 2018 and Arnold. I'm looking for a way to feed the objectID value (the integer NOT the RGB value from the ai Utility) to an ai switch node.

Essentially I'm trying to set up a shader that I can put on to different objects that will change color according to object ID but keep all the other attributes the same. However, I need the color values to be specific not random like what results from using the objectID mode of the aiUtility shader. I should also mention I have a set override that applies the same object ID to each group of objects I want to have a different color. I have set up the colors I need using aiUserDataColor nodes hooked into an ai Switch node. I just need the actual object ID integer to link to the switch node's index attribute to switch between the colors.

Any help would be appreciated. Thanks in advance!

Labels (2)
2 REPLIES 2
Message 2 of 3
timh5D75Z
in reply to: J-Fry

I didn't know you could override the object ID that way. Regardless, I feel like an easier way about this would be to use integer user data on the objects to identify them. You can learn about that workflow here: https://docs.arnoldrenderer.com/display/A5AFMUG/Ai+User+Data+Float+Tutorial

What is the case for this aiSwitch workflow over just assigning materials by hand?

Message 3 of 3
J-Fry
in reply to: J-Fry

Thanks for your response!

Your link definitely describes a working solution. The issue is I am working with literally hundreds of objects so adding an attr to each one is a bit prohibitive (without writing a script). It also makes it harder to add objects later.

So here's what I did:

1. Added a custom override attribute to the aiUserOptions node on the set itself (as opposed to the individual objects as described in your link) and also set it to a value (in this case 1). This was done by writing in:

declare colorID constant FLOAT colorID 1

into the aiUserOptions text field (I set the value for colorID to different values for each set so they will have different colors)

2. Created an aiUserDataFloat node and in the "attribute" field put "colorID" (same as instructed on your link only i used "colorID" instead of "Float")

3. Hooked up the output of the aiUserDataFloat node to the "index" attribute of the switch mode and it works like a charm!

Thanks so much for your help! Your link definitely unlocked the problem.

(BTW, the reason why I want to do this is I am doing some look dev and I want to be able to change one attribute and have all the objects be affected in the render instead of having to change all the shaders individually (since the only attribute that is unique will be base color). I didn't want to use a texture because I didn't want to mess with UVs and I still wanted to be able to adjust the colors by hand within Maya. More than that, I'm really trying to familiarize myself with some of these Arnold Utility nodes as well. Thanks again.)

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report