Hex-tiling
Mikkelsen's practical hexagonal tiling: break texture repetition by randomly rotating, offsetting and blending three overlapping hex cells per pixel. Simple, cheap and fits into existing shaders.
In the family Materials, BRDFs & texturing, texture synthesis
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | MaterialXLoader hextile node (examples/jsm/loaders/materialx/MaterialXHextile.js) docs Via MaterialX hextile; not a general material option. |
| Babylon.js 9.38.0 | Built in | pbrMaterial.textureRepetitionMode (hex tiling mode) + textureRepetitionHexTilingParams docs WebGL2/WebGPU only. |
| Godot 4.7 | None found | |
| Unity | Official add-on | Shader Graph samples > Terrain Sample > Hex layer nodes (LayerHex) docs Shipped as a Shader Graph sample (Terrain Sample), not a core node. |
| Unreal 5.7 | None found | |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
A hexagonal grid is overlaid on UV space. For each pixel the three nearest hex centres are found and each gets a pseudo-random offset (and optionally rotation or mirroring) hashed from its cell id. The texture is sampled once per cell and the three results are blended with weights that fall from 1 at the cell centre to 0 at the edge. To avoid contrast loss in the blend, the weights are sharpened with a power function and, for detail textures, the variance can be rescaled in a histogram-preserving way (as in Heitz-Neyret). For normal maps the three fetched normals should be combined carefully (for example as surface gradients) so lighting stays consistent. Mip level selection uses analytic gradients per cell to avoid seams.
When to choose it
Reach for it when
- repeating texture pattern is obvious across terrain
- tiling visible on large floors and walls
- need a cheap drop-in way to hide repetition
- textures look copy-pasted over big surfaces
Choose it when you want a drop-in anti-tiling operator for terrain, floors and walls with stochastic textures. Prefer Histogram-preserving blending (stochastic texturing) when contrast must be exactly preserved. Prefer Image quilting or authored variation for structured patterns where blending would ghost. Use with Triplanar mapping for rocks.
Field marks
- Ghosting and loss of contrast in the blend regions, especially on high-frequency textures
- Visible hex structure if offsets are too small or the texture has strong directional features
- Mip seams if derivatives from the transformed coordinates are not used
- Rotation of an anisotropic or directional texture causes lighting direction mismatches on normal maps
Presets
Repeating tiles (left) vs stochastic hex-grid tiling (right)
{
"TILES": 6,
"BLEND_POW": 7
}Show GLSL (32 lines)
// Stochastic hex-grid tiling: a triangle grid picks 3 random offsets per fragment and blends them
// with contrast-sharpened barycentric weights. Left: ordinary repeating tiles. Right: hex tiling.
const float TILES = 6.0;
const float BLEND_POW = 7.0;
vec3 tex(vec2 uv) {
vec2 f = fract(uv);
vec3 c = vec3(0.5 + 0.18 * sin(6.2832 * f.x + 1.0) * sin(12.566 * f.y));
c *= vec3(0.9, 0.8, 0.65);
c = mix(c, vec3(0.08, 0.06, 0.05), smoothstep(0.17, 0.1, length(f - vec2(0.3, 0.65))));
c = mix(c, vec3(0.9, 0.85, 0.7), smoothstep(0.02, 0.0, abs(length(f - vec2(0.72, 0.3)) - 0.12)));
c = mix(c, vec3(0.7, 0.2, 0.15), smoothstep(0.025, 0.0, abs(f.x - f.y * 0.5 - 0.4)));
return c;
}
vec2 h2(vec2 p) { return fract(sin(vec2(dot(p, vec2(127.1, 311.7)), dot(p, vec2(269.5, 183.3)))) * 43758.5453); }
vec3 hexTex(vec2 uv) {
vec2 sk = mat2(1.0, -0.57735027, 0.0, 1.15470054) * (uv * 3.4641016);
vec2 base = floor(sk); vec2 tt = fract(sk);
vec3 bary = vec3(tt, 1.0 - tt.x - tt.y);
vec2 v1, v2, v3; vec3 w;
if (bary.z > 0.0) { v1 = base; v2 = base + vec2(0.0, 1.0); v3 = base + vec2(1.0, 0.0); w = vec3(bary.z, bary.y, bary.x); }
else { v1 = base + vec2(1.0, 1.0); v2 = base + vec2(1.0, 0.0); v3 = base + vec2(0.0, 1.0); w = vec3(-bary.z, 1.0 - bary.y, 1.0 - bary.x); }
w = pow(w, vec3(BLEND_POW)); w /= (w.x + w.y + w.z);
return tex(uv + h2(v1)) * w.x + tex(uv + h2(v2)) * w.y + tex(uv + h2(v3)) * w.z;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = fragCoord / iResolution.xy * TILES;
vec3 col = fragCoord.x < 0.5 * iResolution.x ? tex(uv) : hexTex(uv);
if (abs(fragCoord.x - 0.5 * iResolution.x) < 1.0) col = vec3(1.0);
fragColor = vec4(pow(col, vec3(1.0 / 2.2)), 1.0);
}
Attribution: written for this index
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| hex-tiling-specimen | Tesla T4 1920x1080 | 3.88× baseline (light) · 0.128 ms / 0.135 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| hex-tiling-specimen | NVIDIA L4 1920x1080 | 3.28× baseline (light) · 0.052 ms / 0.053 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| hex-tiling-specimen | NVIDIA A100-SXM4-40GB 1920x1080 | 2.40× baseline (light) · 0.069 ms / 0.069 ms · 1.8× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- One phone photo, a whole floor: A flash photo of a small material patch becomes a PBR material that covers a large area without visible repetition. Every map is quilted with the same seams and tiled with the same hex offsets, so albedo, normal and roughness stay registered.
- Surface gradient based bump mapping framework: Blends the three hex-cell normals as surface gradients so shading stays consistent.
Sources
- primaryMorten S. Mikkelsen. Practical Real-Time Hex-Tiling. JCGT 2022.Verified via live page · 2026-11-29
- implementationmmikk (2022). mmikk/hextile-demo. demonstrates hex-tilingGitHub API · license MIT · 2026-11-29