public Particle Create(float creationTime)
 {
     var p = new Particle(creationTime);
     p.LifeTime = 10f;
     Func<float> Rnd01 = () => (float)random.NextDouble();
     Func<float> RndCoord = () => (Rnd01() - 0.5f) * 2.0f;
     //around emitter position
     p.Position = emitterPos + new Vector3(RndCoord(), RndCoord(), RndCoord()) * .1f;
     //speed between [.002, .004]
     p.Velocity = Vector3.Zero;
     //gravity
     p.Acceleration = new Vector3(0, -.4f, 0);
     return p;
 }
 public Particle Create(float creationTime)
 {
     var p = new Particle(creationTime);
     p.LifeTime = 10f;
     Func<float> Rnd01 = () => (float)random.NextDouble();
     Func<float> RndCoord = () => (Rnd01() - 0.5f) * 2.0f;
     //start at emitter position
     p.Position = Emitter;
     //slightly different upward vectors
     var direction = new Vector3(0.3f * RndCoord(), 1, 0.3f * RndCoord());
     //speed between [.2, .4]
     p.Velocity = (.2f + .2f * Rnd01()) * direction;
     p.Acceleration = Wind;
     return p;
 }
        private void InitParticles()
        {
            var rnd = new Random(12);
            Func<float> Rnd01 = () => (float)rnd.NextDouble();
            Func<float> RndCoord = () => (Rnd01() - 0.5f) * 2.0f;
            Func<float> RndSpeed = () => (Rnd01() - 0.5f) * 0.01f;

            bufferParticles = new BufferObject(BufferTarget.ShaderStorageBuffer);

            var data = new Particle[particelCount];
            for (int i = 0; i < particelCount; ++i)
            {
                data[i].position = new Vector2(RndCoord(), RndCoord());
                data[i].velocity = new Vector2(RndSpeed(), RndSpeed());
            }
            bufferParticles.Set(data, BufferUsageHint.StaticCopy);
        }
        private void OnAfterParticleUpdate(Particle particle)
        {
            Func<float> Rnd01 = () => (float)random.NextDouble();
            Func<float> RndCoord = () => (Rnd01() - 0.5f) * 2.0f;

            if (particle.Position.Y < 0)
            {
                //slightly different upward vectors
                var direction = new Vector3(RndCoord(), Rnd01(), RndCoord()).Normalized();
                var speed = particle.Velocity.Length;
                particle.Velocity = direction * speed * 0.7f;
            }
        }