Created
February 10, 2019 22:34
-
-
Save lhog/1d6b03320821a6fafb32e7a7ab62f213 to your computer and use it in GitHub Desktop.
SpherePoints_GoldenAngle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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