Potential functions via toric degenerations