6
$\begingroup$

How can I create a material instance with the instancer in animation nodes?

I have animation nodes creating instances of an object. I change their position based on which object they are, which works fine, because each object has its own position information.

However, I am changing the colour of the object, based on which object it is. This does not work, because it only creates an instance of the object, not the material. therefore, the colour ends up being whatever the colour of the last object was (the last value in the line to be changed to).

Here is an illustration of what I am doing. Can anyone help?

Edit: There was an answer for this instance, but if anyone knows how to create a material instance with animation nodes, please share. Thanks!

enter image description here

$\endgroup$
  • $\begingroup$ You want to use the same material but change the color depending on the object? Or, if you are OK with separate materials that will need changing separately, just click that "9" next to the material name to make a duplicate that will be unlinked from all others. $\endgroup$ – HalfKiloByte Jan 15 '16 at 23:18
  • $\begingroup$ I am looking for a way to create a "template" to easily accomplish a certain result without doing everything 9, 10, or 100 times. So pressing the "9" button for each is not really an option. I am looking for a way to "press the button" through animation nodes, just like I would make an instance of the object. If you know another way to change the colour of just one object, using animation nodes, when it is an instance of another object, that would work too. :) $\endgroup$ – Uncle Snail Jan 16 '16 at 0:15
  • $\begingroup$ If there is a inheritance system for materials in Blender, then it's well hidden. I needed something like that several times, but eventually went with duplication. Perhaps the only solution is Python scripts synchronizing several properties. $\endgroup$ – HalfKiloByte Jan 16 '16 at 0:58
  • $\begingroup$ Okay, it sounds like a good solution. Unfortunately, I don't know much Python... It may be good motivation to learn more though. :) $\endgroup$ – Uncle Snail Jan 16 '16 at 14:00
7
$\begingroup$

At present the method is not to create instances of the material, but to vary vertex color per object. Assuming cycles render, cycles allows per object info on the same material as: random, obj index or vertex color.

(For Blender Internal render, there are other methods, it allows object color etc)

Imitating your case, a basic setup looks like this:

  • instance the object
  • make sure you have "deep copy" so that each object has a different mesh, (like shiftD manual copy in blender)
  • color/set vertex color to set vcolor for each object
  • in cycles use attribute to get that color per object

(note that you don't need to create the vcol before, the node creates it or takes the first existing one) enter image description here

There are other methods for this simple example. But generally it's better to vary this data than:

  • having to manage 100 materials only to change a color.
  • using object index, that may be used in other places, render layers etc
  • switch 2 materials only for ks for this limited case of pure switch

Also, vcol allows more variations of the color, using combine color node (hsv) to vary hue or any other complex rule.

-

Here's an example that uses object index (pass_index) as 0/1 to switch things. But this parameter can very well be used in other places and only works with integers (0, 1, 2...100, 200...).

It is not the best. Still, you may need to use this if the object is not a mesh, but a curve or text. (On texts there are other specific methods too, but for this simplistic switch it's ok)

enter image description here

$\endgroup$
  • $\begingroup$ Do you know of a way to get the vertex colors to show up/update in the texture viewport? I have done what you said and it worked, but now I want to use openGL render, and the vertex colors don't seem to effect it. $\endgroup$ – Uncle Snail Jan 28 '16 at 23:27
  • $\begingroup$ What "new parametr" use "Loop Input" node? I tried use "Vector" with zero succes. Thanks $\endgroup$ – vklidu Nov 5 '17 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.