vogelDiskSample
Generates uniformly distributed 2D sample points inside a unit disk based on the Vogel disk sequence. Given a sample index, the total sample count, and a rotation angle φ, it returns the corresponding vec2 offset on the disk.
Core Advantages
Compared to simple random or grid sampling, this low-discrepancy sequence covers the disk area much more evenly, producing less noise and faster convergence for the same number of samples. It is well suited for real-time multi-sample effects such as DOF blur, SSAO, soft shadows, and denoising.
Common Uses
Depth of Field / aperture blur, using the unit disk as the lens sampling pattern.
Screen-space ambient occlusion (SSAO), soft shadows, and volumetric lighting where disk-shaped local sampling around the current pixel is required.
Building well-distributed disk kernels for post-process blur, bloom, and denoising passes.
Combining with noise or random values (such as IGN) to rotate the sampling pattern per pixel and break up banding or repetitive artifacts.
How to adjust
vogelDiskSample has three main parameters: sampleIndex, samplesCount, and phi.\n\n1) sampleIndex: the sample index, typically iterating from 0 to samplesCount - 1 inside a Loop or for-loop. When used in isolation, changing this index walks along the Vogel spiral, picking different positions on the disk.\n\n2) samplesCount: the total number of samples. It controls how dense and smooth the coverage on the disk is: higher values give smoother blur/occlusion but increase shading cost linearly. Typical ranges for SSAO/DOF are around 8–32 samples.\n\n3) phi: the global rotation angle in radians. Using a per-pixel random φ (for example derived from IGN or hash(uv) * 2π) rotates the sampling pattern differently per pixel and efficiently breaks up banding artifacts; driving φ with time creates a slow rotation of the pattern, adding a subtle dynamic grain.\n\nNote: vogelDiskSample returns offsets on the unit disk. The actual blur radius or sampling radius is controlled by the scale you apply afterwards (for example offset.mul( blurRadius )), which you can tune based on screen resolution or world-space size.
Code Examples
1// Use the Vogel disk sequence to generate a sample offset on the unit disk
2const samplesCount = int(16);
3const phi = time.mul( TSL.PI2 ); // rotate the pattern over time
4
5// Get the disk offset for a given sample index (usually driven by a Loop index)
6const offset = vogelDiskSample( int(0), samplesCount, phi );
7
8// Scale the offset and add it to UV for blur / DOF style effects
9const sampleUV = uv().add( offset.mul( 0.03 ) );