Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SpherePoints_GoldenAngle
vec3 SpherePoints_GoldenAngle(float i, float numSamples) {
const float goldenAngle = PI * (3.0 - sqrt(5.0));
float theta = i * goldenAngle;
float z = (1.0 - 1.0/numSamples) * (1.0 - 2.0 * i / (numSamples - 1.0));
float radius = sqrt(1.0 - z * z);
return vec3(radius * cos(theta), radius * sin(theta), z);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment