Real-time glints (distributed binomial laws)
Renders sparkly surfaces such as glitter, metallic flakes and snow in real time by statistically evaluating how many discrete microfacets in a pixel footprint reflect toward the viewer. Deliot and Belcour use binomial laws over an anisotropic grid.
In the family Materials, BRDFs & texturing, microfacet BRDF
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | None found | |
| Unity | None found | |
| Unreal 5.7 | Built in | Substrate Slab > Glint Density / Glint UVs; requires r.Substrate.Glints=1 docs Substrate materials only; off unless console variable is set. |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Smooth GGX hides the fact that bright sparkle comes from individual facets. Instead of storing a million microfacet normals, the method divides texture space into cells over an anisotropic grid in (position, slope) space aligned with the pixel footprint. In each cell the number of facets that point inside the half-vector footprint follows a binomial distribution whose parameters come from the surface's normal distribution. A hash gives a stable pseudo-random count per cell, so sparkles stay fixed to the surface and animate with the view. Tests across overlapping cells are combined with a closed-form cost independent of footprint size, avoiding per-facet loops. The glint lobe is added to or replaces the smooth specular lobe.
When to choose it
Reach for it when
- car paint flakes should sparkle
- glitter, snow and sand look dull and smooth
- metallic flakes need to glint while moving
- sequins and pearlescent surfaces lack sparkle
- discrete micro-reflections inside a pixel
Choose it for car paint with metallic flakes, glitter, sand, snow, sequins and pearlescent surfaces where a smooth GGX looks lifeless. Prefer plain GGX / Trowbridge-Reitz normal distribution with a normal map for gentle roughness. Prefer Anisotropic GGX for brushed surfaces without discrete sparkle.
Field marks
- Temporal flicker when facets enter and exit the footprint under motion unless accumulated carefully
- Hash correlations show as visible grid patterns at extreme minification
- Facet density parameter has no direct mapping from measured flake data
- Increased cost on mobile GPUs; fewer samples cause noisier sparkles
Presets
Stochastic microfacet glints — discrete metallic flake sparkles over smooth clearcoat
{
"FLAKE_DENSITY": 52,
"ROUGHNESS": 0.24,
"GLINT_INTENSITY": 3.2,
"MICRO_ROUGH": 0.045
}Show GLSL (118 lines)
const float FLAKE_DENSITY = 52.0; // P
const float ROUGHNESS = 0.24; // P
const float GLINT_INTENSITY = 3.2; // P
const float MICRO_ROUGH = 0.045; // P
vec3 hash32(vec2 p) {
vec3 q = fract(vec3(p.xyx) * vec3(0.1031, 0.1030, 0.0973));
q += dot(q, q.yxz + 33.33);
return fract((q.xxy + q.yzz) * q.zyx);
}
float D_GGX(float nh, float a) {
float a2 = a * a;
float d = nh * nh * (a2 - 1.0) + 1.0;
return a2 / (3.14159265 * d * d + 1e-5);
}
// Multi-cell hashed discrete microfacet glint evaluator in tangent slope space
vec3 evalGlints(vec2 uv, vec3 hTan, float density, float macroRough, float microRough) {
float dScale = max(density, 4.0);
vec2 gUv = uv * dScale;
vec2 cell = floor(gUv);
vec2 frac = fract(gUv);
vec2 targetSlope = hTan.xy / max(hTan.z, 0.15);
float mSig = max(microRough, 0.012);
float macSig = max(macroRough, 0.08);
vec3 glint = vec3(0.0);
for (int j = -1; j <= 1; j++) {
for (int i = -1; i <= 1; i++) {
vec2 cid = cell + vec2(float(i), float(j));
vec3 rnd = hash32(cid);
vec3 rnd2 = hash32(cid + vec2(37.2, 91.7));
vec2 center = vec2(float(i), float(j)) + 0.18 + 0.64 * rnd.xy;
float dist2 = dot(frac - center, frac - center);
float spatial = exp(-dist2 * 14.0);
// Discrete flake normal drawn from macro Gaussian slope distribution
float rAng = rnd.z * 6.2831853;
float rMag = sqrt(-2.0 * log(max(rnd2.x, 1e-4))) * macSig * 0.52;
vec2 flakeSlope = vec2(cos(rAng), sin(rAng)) * rMag;
vec2 ds = targetSlope - flakeSlope;
float angular = exp(-dot(ds, ds) / (2.0 * mSig * mSig));
// Subtle prismatic car-paint / metallic flake iridescence
vec3 tint = mix(vec3(0.92, 0.96, 1.0), 0.55 + 0.45 * cos(6.28318 * (rnd2.y + vec3(0.0, 0.18, 0.42))), 0.55);
glint += tint * spatial * angular * (0.7 + 0.6 * rnd2.z);
}
}
return glint;
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
vec3 ro = vec3(0.0, 0.12, 2.55);
vec3 rd = normalize(vec3(uv, -1.55));
vec3 bg = mix(vec3(0.02, 0.025, 0.04), vec3(0.07, 0.09, 0.14), clamp(uv.y + 0.5, 0.0, 1.0));
// Ray-sphere studio specimen
float rad = 0.84;
float b = dot(ro, rd), c = dot(ro, ro) - rad * rad, h = b * b - c;
if (h < 0.0) {
fragColor = vec4(pow(clamp(aces(bg), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
return;
}
float t = -b - sqrt(h);
vec3 p = ro + rd * t;
vec3 n = normalize(p);
vec3 v = -rd;
// Rotate sphere surface coordinates slowly (or via mouse)
float rot = iTime * 0.28;
if (iMouse.z > 0.5 || length(iMouse.xy) > 1.0) {
rot = (iMouse.x / iResolution.x - 0.5) * 3.14159;
}
float cr = cos(rot), sr = sin(rot);
vec3 pr = vec3(cr * n.x - sr * n.z, n.y, sr * n.x + cr * n.z);
// Cubemap-like triplanar UV avoids pole pinching
vec2 surfUv = vec2(atan(pr.z, pr.x) * 0.31831, asin(clamp(pr.y, -0.999, 0.999)) * 0.63662);
vec3 up = abs(n.y) < 0.95 ? vec3(0.0, 1.0, 0.0) : vec3(1.0, 0.0, 0.0);
vec3 T = normalize(cross(up, n));
vec3 B = cross(n, T);
mat3 worldToTan = transpose(mat3(T, B, n));
vec3 l1 = normalize(vec3(0.65 * cos(iTime * 0.4) + 0.2, 0.68, 0.65));
vec3 l2 = normalize(vec3(-0.75, 0.42, 0.55));
vec3 baseCol = vec3(0.08, 0.22, 0.54);
float rough = clamp(ROUGHNESS, 0.06, 0.95);
float ndv = max(dot(n, v), 0.001);
float fres = 0.04 + 0.96 * pow(1.0 - ndv, 5.0);
vec3 col = baseCol * (0.08 + 0.12 * (n.y * 0.5 + 0.5));
// Key light + fill light: smooth GGX + clearcoat + stochastic microfacet glints
for (int k = 0; k < 2; k++) {
vec3 L = (k == 0) ? l1 : l2;
vec3 lCol = (k == 0) ? vec3(1.85, 1.72, 1.55) : vec3(0.65, 0.85, 1.25);
float nl = max(dot(n, L), 0.0);
vec3 H = normalize(L + v);
float nh = max(dot(n, H), 0.0);
float specSmooth = D_GGX(nh, rough * rough) * 0.22;
float coat = D_GGX(nh, 0.045) * fres * 0.45;
vec3 hTan = worldToTan * H;
vec3 glints = evalGlints(surfUv, hTan, FLAKE_DENSITY, rough, MICRO_ROUGH) * max(GLINT_INTENSITY, 0.0);
col += lCol * nl * (baseCol * 0.65 + vec3(0.55, 0.72, 1.0) * specSmooth + coat + glints);
}
// Subtle studio rim environment reflection
vec3 R = reflect(-v, n);
vec3 env = mix(vec3(0.05, 0.08, 0.14), vec3(0.55, 0.68, 0.92), smoothstep(-0.2, 0.8, R.y));
col += env * fres * 0.65;
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| real-time-glints-live | Tesla T4 1920x1080 | 21.4× baseline (heavy) · 0.706 ms / 0.725 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| real-time-glints-live | NVIDIA L4 1920x1080 | 18.6× baseline (moderate) · 0.296 ms / 0.297 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| real-time-glints-live | NVIDIA A100-SXM4-40GB 1920x1080 | 13.8× baseline (moderate) · 0.398 ms / 0.401 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Unidirectional Path Tracing.
Crosses
- Sun glitter from horizon to bow: An ocean that sparkles at every distance. Waves too small to see fold into a correctly stretched specular lobe, and the same filtered slope distribution drives discrete glints, so distant water glitters instead of turning into a flat smear.
Sources
- primaryT. Deliot, L. Belcour (2023). Real‐Time Rendering of Glinty Appearances using Distributed Binomial Laws on Anisotropic Grids. Computer Graphics Forum.Verified via crossref · 2026-11-29doi:10.1111/cgf.14866