# GPU stretched particle

is anyone know how to turn the GPU particle example into Stretch billboard particle based on velocity?

no 1 know?/???/

you have the velocity and you have the stretchfactor, multiply them.

If you use billboards (camera facing) particles you need to calculate the screen space velocity. You can do that by calculating another position with t+1 and then scale the difference based on the effect you want to achieve.

here is some somthing that i try it from 3DParticle sample, how do i make the particle arrow facing to the heading direction, and stretch it base on velocity. where should i start and itās possible to done it all in shader?

i wan to archive smthing like this. Can you guide me?

here is my souce

like this?

Well, as Kosmonautgames said, you have know velocity and since your particle system is copy of XNA particle example you are calculating rotation and size of particles in vertex shader, just modify that part to also include scaling according to velocity (rotate according to velocity instead of using random rotation and scale given axis).

somthing like this , but how u did it in shader?

may i know ātā represent what? i got something like this by calculate rotation base on velocity, but it only rotate base on initial direction . How do i rotate over time base on new direction. Sry for my bad Maths

float2x2 ComputeVelocityRotation(float3 velocity)
{
// Compute a 2x2 rotation matrix.
float c = cos(velocity.x / velocity.y);
float s = sin(velocity.x / velocity.y);

``````return float2x2(c, -s, s, c);
``````

}

Thatās a very simple integral of your acceleration (gravity), -> startvelocity + acceleration * t = current velocity

some of it is correct, but some of them just spin randomly. is my rotation function correct?

They seem to turn in the right direction, but not the right amount.

@kosmonautgames @Alkher i still cant figure out how to make the stretched & rotation rite. pls help me

Question is why some of them point in the right direction and others rotates around their centers after a while ?
Did you succeed in getting the velocity ?

im still confusing what wrong is my calculation, someone told me im actual calculated in screenspace, so the rotation will rotate at screen space direction. I actually not good in calculation. i just ned someone help me modifier the existing shader with stretched particle and rotation with velocity. @Alkher could you help me? i willing to pay some allowance for your help, and also benefit to this community.

here is my souce

Iāll have a look in the evening when iām at home

thank you very much

I did not see your modifications apart from the texture disk wih an arrow.

If you want I can take look at it as well, but I would like to warn you, image you posted are GPU state aware particles using GPU collisions based on depth buffer and normal buffer, while using render targets to save their state which is then sampled in vertex shader to determine position in next updateā¦ it is COMPLETELY different ball game than stateless GPU example you postedā¦ thus if http://community.monogame.net/uploads/default/original/2X/d/d789c3092994d01fd1ac15696576b2e0dbc5582e.png is your end game then you are for quite a ride and particle stretching is least of your problems, then again, if you want, I can take a look at stretching of 3d particles.

yeah the image that i posted involve particle collision, but what im looking now is the velocity rotation and stretching based of velocity. Can you help?

The velocity integral is already in the shader, in ComputeParticlePosition() (explanations are commented in it) where T is ānormalizedAgeā.
You can with all this get the position at current frame-1 and currentframe and as a result get the amount of mouvement between 2 frames.
Problem arises here with the fps you can display. But that 's another thing
The main question here is does your shader uses center of particles and creates quads to drax around this center, or is it fed with the vertices of a quad. The former would be easier to do the particle stretching. But this xna sample uses 4 vertices to feed each particles to the shader, nonetheless it is feasable but wastes computation power to me.

This should have behavior reasonably close to what you posted: http://community.monogame.net/uploads/default/original/2X/d/d789c3092994d01fd1ac15696576b2e0dbc5582e.png

(ofc talking just about stretching and polygon orientation)

If you want shader for this variant then let me know, if you dislike something about this let me know and I can take a look.

With settings closer to what you want:

I am not using data from previous frames, velocity vector is calculated inside shader for given step in world space (from velocity integral as Alkher mentioned), then projected on screen after which rest of vertex position is calculated in screen space. Thus using still same quite efficient system where whole vertex position is calculated purely on GPU.