How to Hide Texture Tiling in Unity: Stochastic Sampling and Other Fixes
A tiled texture repeats the same square across the surface, and from a distance the eye finds the grid: the same dark stone every two metres, in a straight line to the horizon. Stochastic sampling removes the repetition without a bigger texture. It splits the surface into small triangular patches, gives each patch a randomly shifted copy of the texture, and blends neighbouring patches into each other, so no two places on the surface match and there are no seams.

Unity’s Terrain is where most people meet this, and the All In 1 3D Shader does not support the Terrain component; the Terrain section below says what to do instead.
Why tiling shows
Section titled “Why tiling shows”- Distance. Up close you see one tile. Far away you see dozens at once, and any feature that stands out (a crack, a dark stone, a tuft) lines up into a pattern.
- Strong features. A texture with one memorable detail tiles worse than a texture of even noise. The more seamless a texture is at its edges, the more its middle gives it away.
- Mipmaps. At a distance the GPU reads smaller, blurred copies of the texture. Fine detail averages out, and what is left is the large light and dark patches, which are exactly what makes the grid visible.
Fixes that need no shader
Section titled “Fixes that need no shader”Try these first; each one costs little:
- A larger tile with a detail texture. Tile the main texture less often, so the repeat is far apart, and add the fine grain back with a second, small tiling texture (a Detail Map in URP Lit).
- Decals for the memorable details: cracks, stains, puddles, placed by hand where you want them, on a texture that is otherwise even.
- Two textures blended by vertex colour or by a mask, so the ground changes from dirt to grass in places of your choosing, breaking the repeat of both.
- Props. Rocks, plants and debris over a surface hide its grid better than any shader.
How stochastic sampling works
Section titled “How stochastic sampling works”The surface’s UV is laid on a grid of triangles. For each pixel, the shader finds the triangle it is in and samples the texture three times, once per corner of that triangle, each corner with its own random offset. The three samples are blended by how close the pixel is to each corner. Inside a triangle you see a blend of three shifted copies; across the surface the copies keep changing, so the texture never repeats in the same place.
Three things follow from that:
- It costs three texture reads for every texture it is used on, instead of one.
- It softens contrast where copies blend. Three samples mixed together are a little flatter than one. On even textures (gravel, grass, sand, concrete) nobody sees it; on textures with strong lines (bricks, tiles, planks) the blended copies cross each other and look wrong. Those need the fixes above instead.
- The texture must tile. Each copy is still the same texture shifted, so it has to wrap seamlessly at its edges like any tiled texture.

By hand in Shader Graph
Section titled “By hand in Shader Graph”Unity’s built in nodes cannot pick a random offset per triangle, so this takes a Custom Function node. Save the code below as StochasticSample.hlsl in your project, then on the node set Type to File, Source to that file and Name to StochasticSample, and give it the inputs Tex (Texture2D), SS (SamplerState), UV (Vector2) and Scale (Float), and the output Out (Vector4), in that order:
float2 StochasticHash(float2 p){ return frac(sin(float2(dot(p, float2(127.1, 311.7)), dot(p, float2(269.5, 183.3)))) * 43758.5453);}
void StochasticSample_float(UnityTexture2D Tex, UnitySamplerState SS, float2 UV, float Scale, out float4 Out){ // The UV in a grid of triangles float2 skewUV = mul(float2x2(1.0, 0.0, -0.57735027, 1.15470054), UV * Scale); float2 id = floor(skewUV); float3 b = float3(frac(skewUV), 0); b.z = 1.0 - b.x - b.y;
// The triangle's three corners and how close the pixel is to each float2 v1, v2, v3; float3 w; if (b.z > 0) { v1 = id; v2 = id + float2(0, 1); v3 = id + float2(1, 0); w = b.zyx; } else { v1 = id + float2(1, 1); v2 = id + float2(1, 0); v3 = id + float2(0, 1); w = float3(-b.z, 1.0 - b.y, 1.0 - b.x); }
// The original UV's derivatives keep the mipmaps right across the offsets float2 dx = ddx(UV); float2 dy = ddy(UV); Out = SAMPLE_TEXTURE2D_GRAD(Tex.tex, SS.samplerstate, UV + StochasticHash(v1), dx, dy) * w.x + SAMPLE_TEXTURE2D_GRAD(Tex.tex, SS.samplerstate, UV + StochasticHash(v2), dx, dy) * w.y + SAMPLE_TEXTURE2D_GRAD(Tex.tex, SS.samplerstate, UV + StochasticHash(v3), dx, dy) * w.z;}Feed it the surface’s UV through a Tiling And Offset node set to how often the texture repeats (Shader Graph does not apply the material’s Tiling for you), and a Scale around 3.5, and use Out where the Sample Texture 2D node’s colour went. SS can stay unconnected: Shader Graph then passes its default sampler, linear and repeating; connect a Sampler State node to choose another. The function’s name ends in _float, which is the version Shader Graph calls at its default precision; a graph or node set to Half calls StochasticSample_half, so add that copy if you use Half.


All In 1 Shader Nodes has this as a ready node, Stochastic Sampling, with the same Scale and Skew. It returns the texture’s colour, not its alpha.
With All In 1 3D Shader’s Stochastic Sampling
Section titled “With All In 1 3D Shader’s Stochastic Sampling”Don’t own it yet? → Get it on the Unity Asset Store
Tick Stochastic Sampling in the material’s UV Effects (Effects List). It has two settings:
- Grid Scale (
_StochasticScale), 0 to 10, 3.464 by default: how many triangles fit in one tile of the texture. Higher makes smaller patches and more variation; lower makes larger patches, each showing more of the texture whole. - Grid Skew (
_StochasticSkew), 0 to 3, 0.577 by default: the slant of the triangle grid. The default makes even triangles; there is rarely a reason to change it.

It applies to the textures that tile across the surface: the Main Texture, the Normal Map, the top textures of Triplanar Mapping and the textures of Texture Blending. The normal map is sampled with the same offsets as the colour, so its bumps stay on the patches they belong to. Other maps, such as an AO map, are read as usual.
With Triplanar Mapping it covers each projection separately, which suits cliffs and rocks: triplanar stops the stretching on steep faces, and stochastic sampling stops the repeat on each of them. With Texture Blending each of the blended textures gets its own variation, for ground made of two or three materials.

The cost is three texture reads per tiled texture instead of one, which on a floor of one material is small; it adds up on a material with a main texture, a normal map and triplanar on top. See Performance Considerations.
Terrain
Section titled “Terrain”The All In 1 3D Shader does not support Unity’s Terrain component: its materials do not go on a Terrain, and its effects do not reach Terrain layers. For ground made with Terrain, the choices are Terrain’s own shader with the fixes that need no shader above, or a terrain shader that does its own anti tiling. For ground made of meshes (modular floors, a ground mesh exported from a modelling program, rocks and cliffs), the 3D Shader’s Stochastic Sampling works as described here.
What it does not do
Section titled “What it does not do”- Work on Terrain. See above.
- Rescue textures with strong lines. Bricks, tiles and planks look wrong blended; break those up with decals and props.
- Change textures that do not tile. On a character or a prop with a unique texture, it has no repeat to hide and only blurs it.
