Skip to content

Instantly share code, notes, and snippets.

@lhog
Created February 10, 2019 22:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lhog/1d6b03320821a6fafb32e7a7ab62f213 to your computer and use it in GitHub Desktop.
Save lhog/1d6b03320821a6fafb32e7a7ab62f213 to your computer and use it in GitHub Desktop.
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