public static List<Vector3> GetFibonacciSphereVertices(int vertexCount = 1, bool randomize = true)
{
List<Vector3> vertices = new List<Vector3>();
vertices.Capacity = vertexCount;
float random = 1f;
if (randomize)
random = Random.Range(0f, 1f) * vertexCount;
float offset = 2f / vertexCount;
float increment = Mathf.PI * (3f - Mathf.Sqrt(5)); // what is 3 and 5?
float x, y, z, r, phi;
for (int i = 0; i < vertexCount; i++)
{
y = ((i * offset) - 1) + (offset / 2f);
r = Mathf.Sqrt(1f - Mathf.Pow(y, 2));
phi = ((i + random) % vertexCount) * increment;
x = Mathf.Cos(phi) * r;
z = Mathf.Sin(phi) * r;
vertices.Add(new Vector3(x, y, z));
}
return vertices;
}