Jump to content

Using number of incoming points to control particle system birthrate


Memo

Recommended Posts

I have a cached number of points, and I'd like each one to emit particles at a relatively constant rate (30fps, i.e. one particle per source point per frame). I'm thinking if I feed the whole thing as a POP source, and dynamically control the birth rate to match point count it should be fine (the incoming point count isn't changing drastically. It sticks to one number for a while, and then changes to another set after a few seconds, and then another etc, so minor inaccuracies at the point of transition is fine).

 

My challenge is to find a way of getting the number of points into there! According to the documentation there should be a local variable $NPT which is number of points. But I just get 0 when I type that in. I ended up writing the code below (into the Impulse Count parameter) and it seems to work well, but seems overkill just to get the number of points on the current node!. Am I missing some basic syntax on the $NPT?

sop_path = hou.parm('soppath')
sop_node = hou.node(sop_path.eval())
point_count = len(sop_node.geometry().freeze().points())
return point_count

Also any opinions on whether it would be better to use impulse activation with the particle count, or constant activation with particle count * fps? Former seems more sensible to me, but I don't know what's going on behind the scenes so that may not be the case. 

 

Link to comment
Share on other sites

Sorry yes you're right, I'd simplified my question. Actually I'd like to be able to control how many particles per point per frame there is.e.g. currently i'm playing around with a half or a quarter (i.e. impulse_count = point_count/4). So I can have longer trails with fewer particles. Is there no easier way to get point count? Also my method reads the SOP Path, which obviously isn't ideal since the source may be using the node input.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...