# Streaked Particles

Hi, im currently working on a particle system for a game. Anyway, I would like to achieve an effect where the individual particle are streaked, that is, they are stretched in the direction of velocity proportional to their velocity. Basically I would like to have one end of the particle at tits last position, and one end at its current position.
Now, this is all well and good, but I cant think of a way to orient the particle towards the camera without performning 2 cross products per particle, an expensive operation.
Say like this, each particle is a triangle, one vertex is at the last particle position, and the other 2 id like to be opposite each other around the velocity vector kinda, dunnon if im explaining it properly. But yeah, any ideas to do this fast and have the particle face the camera?

You can get a rope-sprite for one cross product, but you’ll have to throw in a normalize, and some change. An alternative might be some kind of image space hackery, with point-sprites and a texture lookup based on velocity (not sure if that’s an idea, or an undigested bit of beef). How many particles are we talkin here, and what’s the typical scale in pixel-space?

No point sprites, they have disadvantages that Im not willing to accept.
I dont know how many particle, but why does that matter? I want it as fast as possible.
My origina thought basially is take the velocity vecotr, take the “to_camera” vector, cross product it, normalise the resultant vector, and then 2 of the verteces of the particle are just its position ± size*resultant_Vector, and the third one is its last position. But this is a cross product and a normalise per particle, ugh.
It obviously doesnt have to be a triangle, could be a rectangle, but yeah…
Im thinking that image space trickery would be slower than the method i described.

The “facing” and “right/up” vectors are the same for the two particle points. You can either re-use them for both locations, OR, as an alternate method, you can cache what the last points were, and just re-use them verbatim in the next frame, without re-calculation.

Can you do it in a vertex program ? I did a vertex program that calculates the vertices of a quad to always face the camera. Should be simple enough to modify it to extrude as well.

I’ll just point out: if you base the lenght on the last position, your results will depend on frame rate. Unless you have a fixed frame rate, you’d be better off to go by actual velocity.

Of course, for a game, this could be Good Enough, in which case, it’s good enough.

Yeah, the reason I suggested rope-sprites was that I figured you wanted something more line-like for long, stretched out particles. In this case, a billboard might be awkward. In case the term “rope-sprite” isn’t universal, it’s a billboard with only 1 axis of rotation, rather than the usual 3 in a traditional sprite. It’s great for laser beams, and so on. There’s the problem of particles disappearing when edge-on, but there are some techniques to fix that, if it matters.

That’s why I asked what the typical size in screen-space is, because if the particles are huge in the screen, then this edge-on effect will be very noticable. Also, techniques might be different depending on the effect being sought. The technique used for distant particles maybe very different from that of those nearby. It really depends on how insane you want to get about it. And if you’re rendering tens of thousands of particles, then you may have to make concessions that could otherwise be avoided with a smaller count. For example, there are nice volumetric techniques that can be implemented in vertex programs that fix the edge-on case, by giving lines a thickness (nVidia has a nice demo of this, IIRC). But this isn’t without a cost.

Hmmm, I may see about writing a vertex program actually, cant see why I didnt think of that…
And yeah, its not frame rate dependant since the velocity is dependant on frame rate too, so the movement of the particles is frame rate independant.

Perhaps you could do this;