3
$\begingroup$

I would like to animate objects in my scene so they appear to blink, each at a different time. I created a cycles material that mixes two shaders (one in non-blink mode, the other in blink mode), and I can set keyframes for the mix shader factor parameter. A couple of problems...

It seems like each blinking element needs its own copy of the blinking material, so I can change the keyframes so they have different on/off times. If I have 8 blinking elements, I need 8 materials, and I need to modify each one so they turn on/off at different times. Is there a more efficient way to animate multiple objects this way with fewer materials?

I want the blinking action to be repetitive, so I don't have to define many on/off keyframes in a long animation. AFAIK, I cannot use the graph editor and f-curves since node parameters don't appear in the editor. Is there a way to "loop" the blinking for a material? Edit: I discovered that I can add the mix shader/factor property to the "Keying Set", so it then appears in the dope sheet editor and graph editor. I can then add a f-curve modifier to it to make it repeat.

In this image, you can see one "comma" blinking on, and the others off. And you can see the material I'm using for it. enter image description here

$\endgroup$
  • $\begingroup$ You can use the object color in the material. It is single user for every object. $\endgroup$ – Leander Dec 13 '18 at 17:57
  • 1
    $\begingroup$ Please explain "object color". I should have mentioned I'm using Cycles $\endgroup$ – stav_nan Dec 13 '18 at 22:03
  • $\begingroup$ I added the tag, although the screenshot makes it clear. And yes, ObjectColor is only available for blender Internal, sorry. $\endgroup$ – Leander Dec 13 '18 at 22:52
  • $\begingroup$ I added a .blend file with my current solution. It uses 1 material and obj indices for animating the blinking effect. It has some problems, but seems to satisfy my goals. $\endgroup$ – stav_nan Dec 14 '18 at 20:59
3
$\begingroup$

It's hacky, and annoying if you want to use it for its intended purpose, but you can animate (or drive) the Pass Index of an object, and access it through an Object Info Input node.

Using a setup like this..

enter image description here

In this example, the Pass Index of each object is animated cyclically, with step-wise interpolation, from 0 to 4. This can yield an sequence like the one below..

enter image description here

..with all the objects sharing the same material, and their cyclic Pass Index animations offset in the dope sheet.

Following stav's suggestion of a rearrangement, here's a version in which the Pass Index is not animated, but used to set the phase: the number of frames a color cycle is offset for the object bearing it. (See comments)

enter image description here

The 'Frame No.' and 'Cycle Period' nodes are both Input > Value nodes, with the value in 'Frame No.' keyframed with a linear interpolation to match the frame number of the animation. The Color Ramp will be swept in the number of frames in the 'Period' node. In this case, the Pass indices of the groups of objects are 0,4 and 8, to get a trailing 1-on, 2-off effect.

$\endgroup$
  • 1
    $\begingroup$ Can you plz share the file so that i can see all the nodes in the file. Thanks $\endgroup$ – atek Dec 14 '18 at 3:04
  • $\begingroup$ @atek No more nodes than an emission shader .. See edit.. 2.79 file attached.. (Apologies.. cycling trough 5 values is probably unnecessarily complicated..the OP probably only needs 2.) $\endgroup$ – Robin Betts Dec 14 '18 at 8:03
  • 1
    $\begingroup$ Very inventive! I like the idea of using the pass index for customizing the animation of individual objects. Your suggestion requires animating the pass index for each object. But I'm wondering if there is a way to statically assign a pass index to an object and use that to compute the animation. For example, define a basic on/off cycle animation, but use the pass index to create a phase shift. That way, I could have one material, x objects with that material, and assign each object a pass index that would cause each one to blink at a different interval, similar to your example. $\endgroup$ – stav_nan Dec 14 '18 at 15:58
  • $\begingroup$ @stav_nan That's exactly what I had thought would be a better way of doing it myself, but would have made the answer rather longer.. Using that method, the shader would have to know what frame it was? Which can be done by driving an Input Value node from the frame number? 'll have a go, if you don't get there first. $\endgroup$ – Robin Betts Dec 14 '18 at 17:21
  • 1
    $\begingroup$ Robin Betts: I'm playing with multiple value nodes. I can animate the values. When added to the active keying set, they appear in the dope sheet and graph editor. AND, I found another post that shows how to derive the frame number from a value (animate a value node, value 1 at frame 1, value x at the end, use linear interp). $\endgroup$ – stav_nan Dec 14 '18 at 18:49
2
$\begingroup$

Have you considered using a short (two frames or more) video file as an Emission texture and have it loop?

enter image description here

You wouldn't have to do anything, just define start frame and assign it as a material. The three video files I made were mp4 files, 20 x 20 pixels each, 6 frames each (2 frames of each color) - each file is around 15Kb , so pretty light.

enter image description here

Video file number one has a Green - Pink - Yellow sequence and is set to "Cyclic", second is Yellow - Dark Orange - Blue, etc.

For some sad reason Blender doesn't pack Movie textures but here's the blend file anyways.

$\endgroup$
  • 1
    $\begingroup$ Pretty interesting solution actually! $\endgroup$ – Blender Sushi Guy Dec 15 '18 at 13:07
  • $\begingroup$ +1.. thump! nothing wrong with this, especially for a one-off. Sometimes you don't need a tool, you need an answer. $\endgroup$ – Robin Betts Dec 15 '18 at 14:15
1
$\begingroup$

instanced suzanne each with different vertex color

random blinking black and white

For this kind of thing, it is quite possible you create Cycles Material that does this "random blinking thing".

You could actually use Emission and some kind of noise that will either gives 1 or 0 depending on the noise.

You can also do use Python drivers or maybe use some kind of shuffle of animations of random pattern 1 and 0.

However, for most control, I would suggest using Animation Nodes or Sverchok add-on to control Cycles Material.

In my example BLEND here, I have a setup using Animation Nodes to simply give Color Per Vertex for each object. So that you can have a single material, but for each object, you pipe in different vertex color. This might be overkill some people say, but then it works.

$\endgroup$
  • $\begingroup$ If you just want ON or OFF randomly, you might actually get away by switching 2 different objects with 2 Materials representing on and off. $\endgroup$ – Blender Sushi Guy Dec 15 '18 at 13:03
  • $\begingroup$ These are good possibilities, but I think Robin Bett's answer is closest to my needs. You've given me some good stuff to explore, though (Sverchok )! $\endgroup$ – stav_nan Dec 15 '18 at 21:32
  • 1
    $\begingroup$ ....I must learn some more AN, Sverchok.. they can both reach behind bits of the standard UI which can be a bit frustrating.. .. waiting for 2.8 to settle before commiting myself. $\endgroup$ – Robin Betts Dec 16 '18 at 2:11
  • $\begingroup$ You can try now, I have tested Animation Nodes 2.1 for few days on Blender 2.8 Beta and seems pretty stable. There are few gotchas, can submit feedbacks to AN developers. Eventually SV and AN can be under one big node dependency. It's very powerful! Don't wait until then, start now when things are actually simpler :) This way you can get used to the new Blender 2.8 UI while figuring out about node workflow. $\endgroup$ – Blender Sushi Guy Dec 18 '18 at 1:14

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.