5
$\begingroup$

I'm trying to create a cycles material to make a particle flare out when it dies in a collision with another particle using Blender 2.72a.

I've managed to get particles to attack and kill other particles using Boid physics, but getting the dead particles to do anything besides disappear or sit there is proving to be a prickly problem.

I'm spit-balling several approaches. My current attempt is to drive emission strength and transparency based on how untimely a particles death is. A particle that dies in a collision will have a velocity of zero and an age less than it's lifetime. However, since dead particles report 0 for their age, you can't use that to determine if a particle just died unnaturally, or if it expired a hundred frames ago. I can get around this if I can retrieve the current frame number for the scene and I've even got the code snippet: bpy.data.scenes['CYCLES'].frame_current I saved it as a script and referenced it in a Script Node that I was able to add to my particle seed, but I can't access the retrieved value.

I was thinking of modifying the scriptlet to populate a global variable or attribute with the frame number and then access it with the Attribute node.

So how can I store the current frame number in a way accessible to the material editor? I've included a link to my blend file. The correct answer doesn't have to implement my code. If you've got an idea that has nothing to do with python, I still want to hear it.

$\endgroup$
4
  • $\begingroup$ One solution would be using particle nodes, and just emit more particles when the first die; This is, however, not in Blender yet/anymore(there is a build, but it's from 2.62... graphicall.org/905). $\endgroup$ Dec 9, 2014 at 17:23
  • $\begingroup$ I'd heard about particle nodes from Andrew Price. From watching MODO tutorials, I can see how versatile they are. Hopefully the Blender devs are giving it priority. $\endgroup$ Dec 9, 2014 at 19:07
  • $\begingroup$ watching someonewithpc's videos, it's frustrating to see how close they came to implementing node particles before pulling back. $\endgroup$ Dec 10, 2014 at 22:07
  • $\begingroup$ To be cleat, it's not my video; But, yeah, I feel the same... There probably is some annoying technical reason for it, thought. $\endgroup$ Dec 10, 2014 at 22:09

1 Answer 1

10
$\begingroup$

One way is to animate it:

  1. Add a value node (⇧ ShiftA)
  2. On the first frame set the value to the frame number (in this case 1) and press I while hovering over the input field.
  3. Do the same for the last frame.
  4. Change the keyframe interpolation to Linear (T) in the graph editor.

enter image description here


Ideally you could just type #frame into the value node, however it seems the value only updates when you toggle in and out of edit mode (or in some way cause the object to re-evaluate). It doesn't update automatically when rendering :/

Hopefully this will be fixed with the new depsgraph :)

$\endgroup$
3
  • $\begingroup$ That's certainly an innovative way to get the frame number. Thanks Gandalf, that might do the trick. $\endgroup$ Apr 20, 2015 at 20:33
  • $\begingroup$ 2018 and I'm pretty sure the #frame scripted expression bug is still completely unresolved. $\endgroup$
    – Logic1
    Oct 26, 2018 at 9:45
  • 3
    $\begingroup$ @Logic1 Seems to be fixed in 2.8 $\endgroup$
    – gandalf3
    Dec 26, 2018 at 22:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .