• Advertisement
Sign in to follow this  

Choosing where to generate particles.

This topic is 1054 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi Everyone,

 

I need some ideas on a good way to place particles for a waterfall system. For a single waterfall, the answer is simple. I would choose a random point along a line segment spanning the top of the waterfall, and have the particle start there with the appropriate force vectors etc.

 

Here's the difficult part: There could be quite a few waterfalls on screen at one time, and all of them would have different widths although I can use a finite set of widths (like small, medium, large river). I would like to ensure that there would be a direct relationship between the number of particles on a waterfall and it's width, so that a wide river has more particles spawn there at a given time than a narrow river, but in a way that is visually (mathematically?) proportional and consistent.

 

I've already went down a few rabbit holes trying devise some overall weighted random choice across differing line segments, but that involves looping through everything and is probably not feasible. I would like to hear how other people would handle the problem.

Share this post


Link to post
Share on other sites
Advertisement

Thanks for the reply Buckeye.

 

I think I know what I'm going to do. I have a recipe from spazzarama's Direct3D Rendering Cookbook that uses a compute shader to generate particles in a massively parallel way. The thing about the example in the book, is that it creates particles from a single rectangular domain to create snow, so that each instance of the particle generator just needs to choose a random spot on that rectangle. In my case though, I need many discontinuous domains to generate particles. To really take advantage of parallelism, I need to condense all those domains into one domain somehow.

 

My plan is to make a structured buffer containing the spawn domain of one river in each element, and make extra entries (copies) for the larger rivers. So if I have one each of a small, medium and large river, the buffer would be something like { large, large, large, medium, medium, small }. Then my compute shader can first choose a random index, with the large river being the most likely choice due to the extra entries, then choose a random place on the domain line between the river banks.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement