Jump to content
Memo

Using number of incoming points to control particle system birthrate

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. 

 

Share this post


Link to post
Share on other sites

POP Source DOP -> Source -> set Emission Type to "All Points".

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Ah right, you could do 

npoints("/obj/geo1/emitter")

as the Impulse Count. Just append /4 if you then want a fourth of that, and so on.

Share this post


Link to post
Share on other sites

ah ok thanks. So I still need to read the SOPPath from the parameter. If the source is coming via the POP Networks input, then what can I do?

Share this post


Link to post
Share on other sites

ah ok thanks. So I still need to read the SOPPath from the parameter. If the source is coming via the POP Networks input, then what can I do?

Just point it to that SOP then?

Share this post


Link to post
Share on other sites

if anyone else is wondering the same thing and comes across this post, the answer is:

npoints(opinputpath("../", 0))

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×