Skip to content

Instantly share code, notes, and snippets.

@rozgo
Forked from sebbbi/BDF2_integrate_HLSL.txt
Created March 28, 2018 00:48
Show Gist options
  • Save rozgo/be20badd56705986b1d8940fa99de228 to your computer and use it in GitHub Desktop.
Save rozgo/be20badd56705986b1d8940fa99de228 to your computer and use it in GitHub Desktop.
BDF2 integrator in HLSL
void BFD2(inout ParticleSimulationDataP1 Particle, float3 Accel)
{
float3 x = Particle.Position;
float3 v = Particle.Velocity;
float3 x1 = Particle.PositionPrev;
float3 v1 = Particle.VelocityPrev;
Particle.Position = (4.0/3.0) * x - (1.0/3.0) * x1 + 1.0 * ((8.0/9.0) * v - (2.0/9.0) * v1 + (4.0/9.0) * Accel * TimeStep2);
Particle.PositionPrev = x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment