Skip to content

Instantly share code, notes, and snippets.

@Bigfoot71
Created October 20, 2025 22:34
Show Gist options
  • Select an option

  • Save Bigfoot71/93a8bc410dcbc786ac6fc699bacb5523 to your computer and use it in GitHub Desktop.

Select an option

Save Bigfoot71/93a8bc410dcbc786ac6fc699bacb5523 to your computer and use it in GitHub Desktop.
Vogel disk
The pre-computed version can be rotated via a 2x2 matrix, while the function takes the rotation angle as a parameter.
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;
}
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