// Update is called once per frame
    void Update()
    {
        var s = Input.mousePosition - mouse0;

        s.Normalize();
        s *= 10;

        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
        {
            Vector2Int v = Vector2Int.RoundToInt(hit.textureCoord * N);
            if (Input.GetKey(KeyCode.Mouse0))
            {
                fluid.AddDensity(v.x, v.y, 100);
                fluid.AddVelocity(v.x, v.y, s.x, s.y);
            }
        }
        var x = Mathf.Sin(Time.time) * 40;
        var y = Mathf.Cos(Time.time) * 40;

        //fluid.AddDensity(N / 2, N / 2, 10);
        //fluid.AddVelocity(N / 2, N / 2, x, y );

        fluid.AddVelocity((int)(N / 1.5), N / 2, -4 * 2, 0);
        fluid.AddVelocity((int)(N / 3), N / 2, 4 * 2, 0);



        //fluid.AddVelocity(N / 4, N / 4, x *-1, y * -1);


        if (Input.GetKeyDown(KeyCode.Space))
        {
            fluid.AddDensity(2, 3, 100);
            fluid.AddVelocity(2, 3, 2, 4);
        }

        tex.filterMode = filtermode;



        FluidStep(fluid);
        RenderFluid();



        mouse0 = Input.mousePosition;
    }
    void Start()
    {
        vBuffer  = new ComputeBuffer(N * N, 4);
        v0Buffer = new ComputeBuffer(N * N, 4);
        kernel   = shader.FindKernel("LinearSolve");
        shader.SetBuffer(kernel, "v", vBuffer);
        shader.SetBuffer(kernel, "v0", v0Buffer);

        shader.SetInt("size", N);



        tex            = new Texture2D(N, N, TextureFormat.RGB24, false);
        tex.wrapMode   = TextureWrapMode.Clamp;
        tex.filterMode = filtermode;

        fluid = new MikeAsh_Fluid(0.1f, 0.0001f, 0.0001f, N);

        RenderFluid();

        fluid.AddDensity(2, 3, 100);
        fluid.AddVelocity(2, 3, 2, 4);
    }