since you can't have multiple override material per renderlayer, I need to create one material that assigns different nodes depending on the ObjectID. At the moment I use a combination of 'mix' nodes with 'greater than' nodes driving the blend value. This setup assigns colors for IDs 11-13 and renders everything else black. I would rather have a switch node where I plug in an integer at the top, and having color or material inputs for each number. Does such a thing exist? (Also could I use a custom attribute instead of ObjID? ...but that should probably a seperate question...) thx
-
$\begingroup$ I think the closest thing to a pre-built switch node would be the ColorRamp node, but it's only good for RGB, not image textures. By the looks of it, you're looking at matching values (object ids) with image textures and I haven't seen any node type that allows for a) pairing up values with image textures and b) allow for a variable number of inputs (which is what a "switch" node would need.) $\endgroup$– Patrick MarchandCommented Jun 9, 2016 at 21:47
2 Answers
Since there is no switch node, I just created groups of the setup that I did earlier (switch shader and switch color). It's limited to 10 inputs, but that should be enough for what I'm doing...otherwise I will extend it. But a real switch node where you can set any number of inputs would be great...just sayin...
I asked an almost identical question a few days ago, and came up with my own node group. Instead of using comparisons, it uses Mix Shaders (but could easily use MixRGB nodes instead) and Subtract nodes (this works because the Mix shader clips its Fac input).
Unfortunately, extending it requires editing the node group, but it's mostly just copy/paste, so it shouldn't be too bad. (You don't have to edit the numbers in the Subtract nodes at all.)