Jump to content
  • Advertisement
Sign in to follow this  
michael879

point sprite trails

This topic is 4530 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

I saw this particle engine that could make particles leave trails behind them. Does anyone know how they do this? Im using point sprites but even with textured quads merely stretching them doesnt work if the path is curved..

Share this post


Link to post
Share on other sites
Advertisement
The easiest way is to remember the last x positions of your object. Then render the object at each of the remembered positions (applying a transparency if you want). This is how something like mouse trails works. Speaking of mouse trails, its been a while. I think I'mma have to enable them now.

Share this post


Link to post
Share on other sites
yea but lets say you want a line trail following your particle. How could you do that? just small increments so it looks like a line?

Share this post


Link to post
Share on other sites
The trick is modelling the particle movements independently once they've been emitted. Simplest thing is to have them move slowly away from their "birth place" and fall slowly according to gravity - fading out over the course of their lifetime.

The emitter should be set to emit a number of new particles (possibly reusing recently died ones) per unit of time; moving the emitter will mean that the particle stream follows it. Thus you end up with a trail - if your emitter moves in a curve/arc pattern then so will the particle trail.

Depending on how accurate you want your effect there are other physical properties you could model, but the above should do what you want.

hth
Jack

Share this post


Link to post
Share on other sites
it can already do that and that wasnt the question. I saw a picture of this thing and it was like a sphere of circles (like in an explosion) moving away from the center. Out of every circle was a triangle leading back to the center and showing the path of the circle. If the circle had arcd the trail would have arcd too. I could just make particles come out of each circle but it still wouldnt rly look the same.

Share this post


Link to post
Share on other sites
one (slow?) solution is to save the last 3-5 locations of the particle and calculate a spline between these points.

spline interploates a round smooth polynomial between the points so it should look nice. You can read more on the theory behind it and interpolate the direction vectors at these points (not only the location vectors).

To draw the spline I guess you would need some triangle strip...


sounds pretty slow and alot of work for such an effect... i bet theres a better way.

Share this post


Link to post
Share on other sites
In almost all cases for production particle systems, this effect is just achieved by remembering the last N positions (and, if appropriate, the last N sizes) for the particle, and then rendering a multi-segment line that's the size of the particle - just stitch together a triangle strip. This works just fine if your frame rate is moderately high and moderately consistent.

If you do want something smoother, something like Catmull-Rom splines are fairly handy for this sort of thing, as they're pretty cheap to evaluate, and (if memory serves) they actually go through all of their control points. I'd only worry about doing that, though, if you're concerned about how static shots look, or if particle trails are an important gameplay element.

Btw, Jack's suggestion is also closer to the mark than you might think: He's just suggesting using particles along the path, instead of line segments. If your emission rate is high enough, you end up with basically the same result - it's pretty much just a matter of aesthetics at that point.

Share this post


Link to post
Share on other sites
Quote:

and then rendering a multi-segment line that's the size of the particle - just stitch together a triangle strip.


how would I do that? Thats probably all I need for now.

Share this post


Link to post
Share on other sites
Well, you'd have a strip that looked sort of like this:

A_C_E_G
|\|\|\|
B-D-F-H


(or, you might reverse the winding - in which case the \ would be /)

For each frame you'd store where the top and bottom of the vertical axis of the particle is. Then G=top[N],H=bottom[N],E=top[N-1],F=bottom[N-1],C=top[N-2],D=bottom[N-2], etc. I would expect that you would want somewhere between 8 and 32 segments, depending on what you're doing. As you store a new segment, you'd discard the oldest one.

When you're just starting the trail out, you can just copy the new values throughout the entire array, or make the tail out of degenerate triangles (which the GPU will basically discard). So, you can do this with a static index buffer and a dynamic vertex buffer.

Good luck,
Jason

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!