Created
October 20, 2025 22:34
-
-
Save Bigfoot71/93a8bc410dcbc786ac6fc699bacb5523 to your computer and use it in GitHub Desktop.
Vogel disk
This file contains hidden or 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
| The pre-computed version can be rotated via a 2x2 matrix, while the function takes the rotation angle as a parameter. |
This file contains hidden or 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
| vec2 VogelDiskSample(int sampleIndex, int samplesCount, float rotation) | |
| { | |
| const float goldenAngle = 2.399963; | |
| float r = sqrt(float(sampleIndex) + 0.5) / sqrt(float(samplesCount)); | |
| float theta = float(sampleIndex) * goldenAngle + rotation; | |
| return vec2(cos(theta), sin(theta)) * r; | |
| } |
This file contains hidden or 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
| import math | |
| def vogel_disk_sample(index, total_samples): | |
| golden_angle = 2.399963229728653 | |
| r = math.sqrt((index + 0.5) / total_samples) | |
| theta = index * golden_angle | |
| x = r * math.cos(theta) | |
| y = r * math.sin(theta) | |
| return (x, y) | |
| for n in [4, 8, 16]: | |
| print(f"\nconst vec2 VOGEL_DISK_{n}[{n}] = vec2[{n}](") | |
| for i in range(n): | |
| x, y = vogel_disk_sample(i, n) | |
| comma = "," if i < n - 1 else "" | |
| print(f" vec2({x:.6f}, {y:.6f}){comma}") | |
| print(");") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment