Water flow From Bottom to Top using Metal Kit iOS
<p>I am creating an application, in which water will flow from bottom to top. i did many changes using source from <a href="https://github.com/FlexMonkey/ParticleLab" rel="nofollow noreferrer">https://github.com/FlexMonkey/ParticleLab</a></p>

<p>Please find video on link below, this is look like Milk, but i am trying to make it as real Water Flow.
<a href="http://expirebox.com/download/6e3c11ca4fb969df976b51628d1d9c89.html" rel="nofollow noreferrer">http://expirebox.com/download/6e3c11ca4fb969df976b51628d1d9c89.html</a></p>

<p><a href="https://i.stack.imgur.com/jTClu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jTClu.png" alt="enter image description here"></a></p>

<pre><code>func resetParticles(edgesOnly: Bool = false, distribution: Distribution = Distribution.Gaussian)
{
    func rand() -&gt; Float32
    {
        return Float(drand48() * -20.005)
    }

    func rand2() -&gt; Float32
    {
        return Float(drand48() * 4)
    }

    let imageWidthDouble = Double(imageWidth/8)
    let imageHeightDouble = Double(Float(imageHeight)/1)
    let randomSource = GKRandomSource()
    let randomWidth: GKRandomDistribution
    let randomHeight: GKRandomDistribution

    switch distribution
    {
    case .Gaussian:
        randomWidth = GKGaussianDistribution(randomSource: randomSource, lowestValue: 0, highestValue: Int(imageWidthDouble))
        randomHeight = GKGaussianDistribution(randomSource: randomSource, lowestValue: 0, highestValue: Int(imageHeightDouble))

    case .Uniform:
        randomWidth = GKShuffledDistribution(randomSource: randomSource, lowestValue: 0, highestValue: Int(imageWidthDouble))
        randomHeight = GKShuffledDistribution(randomSource: randomSource, lowestValue: 0, highestValue: Int(imageHeightDouble))
    }

    for index in particlesParticleBufferPtr.startIndex ..&lt; particlesParticleBufferPtr.endIndex
    {
        var positionAX = Float(randomWidth.nextInt())
        var positionAY = Float(randomHeight.nextInt())

        var positionBX = Float(randomWidth.nextInt())
        var positionBY = Float(randomHeight.nextInt())

        var positionCX = Float(randomWidth.nextInt())
        var positionCY = Float(randomHeight.nextInt())

        var positionDX = Float(randomWidth.nextInt())
        var positionDY = Float(randomHeight.nextInt())
        // print("\(positionAX) \(positionBX) \(positionCX) \(positionDX)")
        // print("\(positionAY) \(positionBY) \(positionCY) \(positionDX)")
        if edgesOnly
        {
            let positionRule = Int(arc4random() % 4)

            if positionRule == 0
            {
                positionAX = 0
                positionBX = 0
                positionCX = 0
                positionDX = 0
            }
            else if positionRule == 1
            {
                positionAX = Float(imageWidth)
                positionBX = Float(imageWidth)
                positionCX = Float(imageWidth)
                positionDX = Float(imageWidth)
            }
            else if positionRule == 2
            {
                positionAY = 0
                positionBY = 0
                positionCY = 0
                positionDY = 0
            }
            else
            {
                positionAY = Float(imageHeight)
                positionBY = Float(imageHeight)
                positionCY = Float(imageHeight)
                positionDY = Float(imageHeight)
            }
        }

        let particle = Particle(A: Vector4(x: positionAX + 400 + rand(), y: positionAY, z: -rand2(), w: rand()),
            B: Vector4(x: positionBX + 400 + rand(), y: positionBY, z: rand2(), w: rand()),
            C: Vector4(x: positionCX + 400 + rand(), y: positionCY, z: -rand2(), w: rand()),
            D: Vector4(x: positionDX + 400 + rand(), y: positionDY, z: rand2(), w: rand()))

        particlesParticleBufferPtr[index] = particle
    }
}
</code></pre>