vertex shader particle physics kinematic formulas

Started by
4 comments, last by brucedjones 10 years, 8 months ago

I'm working on doing some basic particle physics in my vertex shader and I'm trying to make gravity work properly. Here is what I have now in glsl:


vec3 gravity = vec3(0.0, -9.8, 0.0);

pos.xyz += velocityTime.xyz * timeElapsed + (0.5 * gravity * timeElapsed * timeElapsed);

While this is technically correct it doesn't take into account the mass of the particle or air resistance. I have seen some formulas that might work but they seem to contain a square root which I want to avoid. It is more important that this look convincing rather than be mathematically correct so I am willing to make some approximations. I'm basically looking for a formula where heavier particles fall faster than light ones according to physical laws. I know this is basically high school level physics I'm talking about but It doesn't really translate into development very well (hence the square root). Does anyone know how I would modify my formula to take these into account?

Advertisement

Air resistance is predominantly a function of surface area, a simple approach to implement it would be a particle size dependent modification to the acceleration of the particle, which acts in the opposite direction to the direction of motion.

Heavy objects do not fall faster than light objects... They are simply heavier.

Heavy objects do not fall faster than light objects... They are simply heavier.

I know that in a vacuum this is always true but the mass to surface area ratio will effect the speed of falling when air resistance is taken into account.

I stand corrected. I got mixed up between acceleration and velocity and didnt take the time to check the correct equation.

Have a look at this, Drag Coefficient

The equation for drag coefficient is as follows,

Cd = 2*Fd/rho*v*v*A

where, Cd = Drag Coefficient,

Fd = drag force

rho = fluid density

v = object velocity

A = object surface area

An object with a higher mass will attain a greater terminal velocity. You could simplify this equation, at the expense of accuracy, by replacing the v*v term with just v, avoiding the need for any square rooting.

The equation for drag coefficient is as follows,

Cd = 2*Fd/rho*v*v*A

where, Cd = Drag Coefficient,

Fd = drag force

rho = fluid density

v = object velocity

A = object surface area

Wait I'm confused. How can I know the velocity of the object in order to do the calculation if that's what I'm calculating? Also the equation for drag force contains the drag coefficient which in turn requires the force of drag to calculate.

Well a simple approach would be to just calculate a limiting velocity. A better approach would be to apply the drag force as a modification to acceleration.

The following needs to be specifed, Cd (0.47 for a sphere), A (4*pi*radius for a sphere), rho (1.2 for air).

For v you use the value at the current time step, velocityTime.xyz in your case.

Now all your terms are specified and you can use the equation to calculate the drag force, Fd, which will act as a modification to the acceleration term in your equation.

Your additional acceleration will be Fd/m, noting that this will apply in the direction opposite to the direction of motion

This topic is closed to new replies.

Advertisement