private void DispatchUpdatePositionAndVelocity()
        {
            int updateKernel = computeShader.FindKernel("UpdatePositionAndVelocity");

            computeShader.SetInt("Width", lifetimesBuffer.count);
            computeShader.SetBuffer(updateKernel, "Lifetimes", lifetimesBuffer);
            computeShader.SetBuffer(updateKernel, "Motions", motionsBuffer);
            computeShader.SetBuffer(updateKernel, "PositionsREAD", positionsBuffers[READ]);
            computeShader.SetBuffer(updateKernel, "VelocitiesREAD", velocitiesBuffers[READ]);
            computeShader.SetBuffer(updateKernel, "PositionsWRITE", positionsBuffers[WRITE]);
            computeShader.SetBuffer(updateKernel, "VelocitiesWRITE", velocitiesBuffers[WRITE]);
            computeShader.Dispatch(updateKernel, Groups(lifetimesBuffer.count), 1, 1);
            ComputeUtilities.Swap(positionsBuffers);
            ComputeUtilities.Swap(velocitiesBuffers);
        }
        private void DispatchSolveCollisions()
        {
            int solveConstraintsKernel = computeShader.FindKernel("SolveCollisions");

            computeShader.SetInt("Width", lifetimesBuffer.count);
            computeShader.SetBuffer(solveConstraintsKernel, "IndexMap", hash.IndexMap);
            computeShader.SetBuffer(solveConstraintsKernel, "Table", hash.Table);
            computeShader.SetTexture(solveConstraintsKernel, "_TerrainDistanceField", terrainSystem.terrainDistanceField);
            computeShader.SetBuffer(solveConstraintsKernel, "Lifetimes", lifetimesBuffer);
            computeShader.SetBuffer(solveConstraintsKernel, "PositionsREAD", positionsBuffers[READ]);
            computeShader.SetBuffer(solveConstraintsKernel, "VelocitiesREAD", velocitiesBuffers[READ]);
            computeShader.SetBuffer(solveConstraintsKernel, "PositionsWRITE", positionsBuffers[WRITE]);
            computeShader.SetBuffer(solveConstraintsKernel, "VelocitiesWRITE", velocitiesBuffers[WRITE]);
            computeShader.Dispatch(solveConstraintsKernel, Groups(lifetimesBuffer.count), 1, 1);
            ComputeUtilities.Swap(positionsBuffers);
            ComputeUtilities.Swap(velocitiesBuffers);
        }