# Choosing where to generate particles.

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

## 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 on other sites

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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 9
• 13
• 9
• 9
• 15
• ### Forum Statistics

• Total Topics
634075
• Total Posts
3015349
×