# Randomized tiling function, eliminate repeating patterns in your textures!

**URL:** <https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519>\
**Category:** Asset Creation\
**Tags:** unreal-engine\
**Created:** [April 5, 2019, 1:13am UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519 "2019-04-05T01:13:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![witch-dev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/witch-dev/32/465106_2.png) [@witch-dev](https://forums.unrealengine.com/u/witch-dev)\
**Post date:** [April 5, 2019, 1:13am UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/1 "2019-04-05T01:13:49Z")

</div>

Thanks to this marketplace thread: [wip-stochastic-height-blending-node-for-material-graph-never-see-tiling-textures-again](https://forums.unrealengine.com/unreal-engine/marketplace/1602319-wip-stochastic-height-blending-node-for-material-graph-never-see-tiling-textures-again) I found out about this paper: [Procedural Stochastic Textures by Tiling and Blending](https://eheitzresearch.wordpress.com/738-2/).  
I implemented the tiling method shown in the paper (the main point of the paper is actually some kind of “Histogram-preserving blending” but I wasn’t interested in that part since I knew I could use my existing height information for blending), I wasn’t entirely satisfied because I couldn’t manipulate the individual texture samples easily (like rotate, mirror or scale them on a per tile basis for additional randomization). I now implemented a different a solution based on two offset square tiles + and a third rotated by 45°. The function is written with my packed landscape textures in mind (two RGBA textures one with color and roughness and the other with two channel normal, AO and height), the function is commented and changing it for different texture setups shouldn’t be difficult. If you are changing to a different texture setup there are some specifics in the function regarding swapping/flipping some channels of the normal map for rotation and mirroring which you have to watch out for.  
It works very well for organic textures, for something like a brig wall probably not so much. (Maybe if the offsets would be modified so that they happen at fixed steps to match the size of the brigs or something, but I don’t think that it is the best solution for those cases.)  
Default texture:

 ![witchtiled_defaulttiling0.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/8/e8b2c6909f889d6f4585635dbd98a67503a5bb69.jpeg)  
Randomized:  
 ![witchtiled_randomtiling1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/7/e/7e5b0f45fac0c04e4f7708de5483fcc944ef7f0d.jpeg)  
Debug views showing how the tiles are composed together:  
 ![witchtiled_debugtiling0.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/8/687b756e013ff940dcb6c0c9927b3963f3a20cb6.jpeg)  
 ![witchtiled_debugtiling1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/5/3/530d1e3b5ad570c0d29903cfacdcafd71e95d68a.jpeg)  
Depending on the value you set for “tileBlendWeight” the influence between the tiling pattern against the textures height map can be changed with lower values leading to a stronger randomized effect, though it will also start to heavily weight towards the heigher areas in your height map. The other parameters should be easy to figure out especially if you utilize the debug view.  
The function was written for version 4.22.0 ( Which finally has a RGBA output on texture samplers and I used it, so no idea if that is going to break in earlier Unreal versions).  
If you want to try it, just copy the text in the “randomizedTiledSampling.txt” file into a new function (delete the default output node first).  
An example project with a texture and an optimized material set up can be found here: [GitHub - WitchDev/RandomizedTilingMaterials](https://github.com/WitchDev/RandomizedTilingMaterials)  
Edit: There is one connection going directly into “texcoord” which should be connected to the respective “function input” instead.

---

<div class="post-metadata">

**Author:** ![Steve\_T](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Steve\_T](https://forums.unrealengine.com/u/Steve_T)\
**Post date:** [April 5, 2019, 11:10am UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/2 "2019-04-05T11:10:19Z")

</div>

This looks insane! Thanks!

---

<div class="post-metadata">

**Author:** ![Gallonmate](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gallonmate](https://forums.unrealengine.com/u/Gallonmate)\
**Post date:** [April 5, 2019, 5:17pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/3 "2019-04-05T17:17:17Z")

</div>

Woah awesome. Just wanted to confirm I pasted this into a 4.20 project.Like you said the texture samples don’t have RBGA in older ue4, so there’s just nothing connected from the textures. But by just wiring the color and normal map anyways, the function still basically works in 4.20.

Also here’s a blueprint reader with your code pasted for others to view the code setup [Randomized tiling function made by witch-dev posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4](https://blueprintue.com/blueprint/l3n_xi28/)

I wonder if this can be used in an ocean material or other applications.

---

<div class="post-metadata">

**Author:** ![witch-dev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/witch-dev/32/465106_2.png) [@witch-dev](https://forums.unrealengine.com/u/witch-dev)\
**Post date:** [April 5, 2019, 10:20pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/4 "2019-04-05T22:20:33Z")

</div>

> [@Gallonmate](#):
>
> Woah awesome. Just wanted to confirm I pasted this into a 4.20 project.Like you said the texture samples don’t have RBGA in older ue4, so there’s just nothing connected from the textures. But by just wiring the color and normal map anyways, the function still basically works in 4.20.
> 
> Also here’s a blueprint reader with your code pasted for others to view the code setup [Randomized tiling function made by witch-dev posted by anonymous | blueprintUE | PasteBin For Unreal Engine](https://blueprintue.com/blueprint/l3n_xi28/)
> 
> I wonder if this can be used in an ocean material or other applications.

Thanks for linking the blueprint reader didn’t know that exists.  
Regarding the ocean material, you can definetely apply panning to the individual texture samplers and you can even pan the tiles for the samplers around. I’m not certain that it is ideal for oceans though.  
Also, I noticed that one of the texture coordinate inputs is connected directly to “texcoord” and not the function input, if someone uses the function that should be fixed. Else you might run into weird behaviour when changing the input into the function.

---

<div class="post-metadata">

**Author:** ![Bariudol](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bariudol](https://forums.unrealengine.com/u/Bariudol)\
**Post date:** [April 9, 2019, 1:48pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/5 "2019-04-09T13:48:16Z")

</div>

This is amazing. I was looking into building something like this and found your function. Thanks!

---

<div class="post-metadata">

**Author:** ![Magneto](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magneto/32/88717_2.png) [@Magneto](https://forums.unrealengine.com/u/Magneto)\
**Post date:** [April 15, 2019, 6:54pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/6 "2019-04-15T18:54:33Z")

</div>

This looks really useful but I’ve never used a material function before so just wondering if someone could do a quick step by step guide to get it working?

Ill take a look at youtube in the meantime but it would be helpful for everyone who comes across this in future to get this working quickly. Thanks!

---

<div class="post-metadata">

**Author:** ![Gampersnaz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Gampersnaz](https://forums.unrealengine.com/u/Gampersnaz)\
**Post date:** [April 16, 2019, 11:43am UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/7 "2019-04-16T11:43:23Z")

</div>

Looks great! Now to make it world aligned.

---

<div class="post-metadata">

**Author:** ![n00854180t](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@n00854180t](https://forums.unrealengine.com/u/n00854180t)\
**Post date:** [April 16, 2019, 7:44pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/8 "2019-04-16T19:44:10Z")

</div>

> [@Magneto](#):
>
> This looks really useful but I’ve never used a material function before so just wondering if someone could do a quick step by step guide to get it working?
> 
> Ill take a look at youtube in the meantime but it would be helpful for everyone who comes across this in future to get this working quickly. Thanks!

First create a new Material Function asset.

Copy the text from the .txt file OP attached.

Paste into the window of the Material Function.

Then you can use it in a Material.

---

<div class="post-metadata">

**Author:** ![Magneto](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magneto/32/88717_2.png) [@Magneto](https://forums.unrealengine.com/u/Magneto)\
**Post date:** [April 17, 2019, 11:47am UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/9 "2019-04-17T11:47:41Z")

</div>

> [@n00854180t](#):
>
> First create a new Material Function asset.
> 
> Copy the text from the .txt file OP attached.
> 
> Paste into the window of the Material Function.
> 
> Then you can use it in a Material.

Thanks though I had done that already. It’s using it within a material that im unsure of. I added the material function call and im unsure what half the inputs and outputs need to be set as with good results?

I did manage to get something to appear after messing about but it doesn’t look right but I can see the tiled effect which is cool!

---

<div class="post-metadata">

**Author:** ![witch-dev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/witch-dev/32/465106_2.png) [@witch-dev](https://forums.unrealengine.com/u/witch-dev)\
**Post date:** [April 17, 2019, 9:58pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/10 "2019-04-17T21:58:50Z")

</div>

> [@Magneto](#):
>
> Thanks though I had done that already. It’s using it within a material that im unsure of. I added the material function call and im unsure what half the inputs and outputs need to be set as with good results?
> 
> I did manage to get something to appear after messing about but it doesn’t look right but I can see the tiled effect which is cool!

I’ll try to upload an example project within a few days to show how it works (with an updated version of the function).

---

<div class="post-metadata">

**Author:** ![Thunder\_Owl](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Thunder\_Owl](https://forums.unrealengine.com/u/Thunder_Owl)\
**Post date:** [April 21, 2019, 1:11pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/11 "2019-04-21T13:11:05Z")

</div>

> [@witch-dev](#):
>
> I’ll try to upload an example project within a few days to show how it works (with an updated version of the function).

That would be / will be awesome 🙂 Thank You.

---

<div class="post-metadata">

**Author:** ![Magneto](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magneto/32/88717_2.png) [@Magneto](https://forums.unrealengine.com/u/Magneto)\
**Post date:** [April 21, 2019, 1:33pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/12 "2019-04-21T13:33:52Z")

</div>

> [@witch-dev](#):
>
> I’ll try to upload an example project within a few days to show how it works (with an updated version of the function).

Looking forward to it. Thanks!

---

<div class="post-metadata">

**Author:** ![witch-dev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/witch-dev/32/465106_2.png) [@witch-dev](https://forums.unrealengine.com/u/witch-dev)\
**Post date:** [April 25, 2019, 8:20pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/13 "2019-04-25T20:20:39Z")

</div>

I’ve uploaded an example project: [GitHub - WitchDev/RandomizedTilingMaterials](https://github.com/WitchDev/RandomizedTilingMaterials)

---

<div class="post-metadata">

**Author:** ![Thunder\_Owl](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Thunder\_Owl](https://forums.unrealengine.com/u/Thunder_Owl)\
**Post date:** [April 26, 2019, 7:58am UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/14 "2019-04-26T07:58:16Z")

</div>

Big Thanks for example!

---

<div class="post-metadata">

**Author:** ![Magneto](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/magneto/32/88717_2.png) [@Magneto](https://forums.unrealengine.com/u/Magneto)\
**Post date:** [April 30, 2019, 2:24pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/15 "2019-04-30T14:24:16Z")

</div>

> [@witch-dev](#):
>
> I’ve uploaded an example project: [GitHub - WitchDev/RandomizedTilingMaterials](https://github.com/WitchDev/RandomizedTilingMaterials)

Thanks for this!

---

<div class="post-metadata">

**Author:** ![Solo-Paul](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Solo-Paul](https://forums.unrealengine.com/u/Solo-Paul)\
**Post date:** [June 25, 2019, 2:53pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/16 "2019-06-25T14:53:46Z")

</div>

so it wont work for default textures? i guess i need to merge textures myself. or add addition textureobjects somehow?

---

<div class="post-metadata">

**Author:** ![witch-dev](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/witch-dev/32/465106_2.png) [@witch-dev](https://forums.unrealengine.com/u/witch-dev)\
**Post date:** [June 26, 2019, 12:47am UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/17 "2019-06-26T00:47:11Z")

</div>

> [@Solo-Paul](#):
>
> so it wont work for default textures? i guess i need to merge textures myself. or add addition textureobjects somehow?

Yes, the function as is in the project is set up with my specific texture packing. The channel I’m using for height is often called displacement or depth depending on the program you use for textures.  
For more texturobjects just look at the current “albedoRough” input in the “TiledHeightBlend” Material Function and build the new texture input from there, it’s just a few nodes to add an additional texture.  
If you don’t have height information available calculating average colors(just add your RGB channels and divide by 3) or a normal map based blending should also lead to good results. I just went with height since I was using that already in my landscape textures anyway and it’s simple to blend with.  
The place you’d have to change for different blending methods are the connections going into the block commented with “texture height for blending” in the “TiledHeightBlend” Material Function.

---

<div class="post-metadata">

**Author:** ![JosephJames](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/josephjames/32/580184_2.png) [@JosephJames](https://forums.unrealengine.com/u/JosephJames)\
**Post date:** [June 30, 2019, 6:13am UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/18 "2019-06-30T06:13:22Z")

</div>

Working on making this triplanar for those hoping for a solution. Will post once progress is made.

---

<div class="post-metadata">

**Author:** ![VolumetricDog](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/volumetricdog/32/624243_2.png) [@VolumetricDog](https://forums.unrealengine.com/u/VolumetricDog)\
**Post date:** [September 16, 2019, 12:18pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/19 "2019-09-16T12:18:08Z")

</div>

This is awesome! Thak you!!

---

<div class="post-metadata">

**Author:** ![LucianoJacomeli](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LucianoJacomeli](https://forums.unrealengine.com/u/LucianoJacomeli)\
**Post date:** [October 19, 2019, 5:31pm UTC](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519/20 "2019-10-19T17:31:35Z")

</div>

> [@witch-dev](#):
>
> Thanks to this marketplace thread: [wip-stochastic-height-blending-node-for-material-graph-never-see-tiling-textures-again](https://forums.unrealengine.com/unreal-engine/marketplace/1602319-wip-stochastic-height-blending-node-for-material-graph-never-see-tiling-textures-again) I found out about this paper: [Procedural Stochastic Textures by Tiling and Blending](https://eheitzresearch.wordpress.com/738-2/).  
> I implemented the tiling method shown in the paper (the main point of the paper is actually some kind of “Histogram-preserving blending” but I wasn’t interested in that part since I knew I could use my existing height information for blending), I wasn’t entirely satisfied because I couldn’t manipulate the individual texture samples easily (like rotate, mirror or scale them on a per tile basis for additional randomization). I now implemented a different a solution based on two offset square tiles + and a third rotated by 45°. The function is written with my packed landscape textures in mind (two RGBA textures one with color and roughness and the other with two channel normal, AO and height), the function is commented and changing it for different texture setups shouldn’t be difficult. If you are changing to a different texture setup there are some specifics in the function regarding swapping/flipping some channels of the normal map for rotation and mirroring which you have to watch out for.  
> It works very well for organic textures, for something like a brig wall probably not so much. (Maybe if the offsets would be modified so that they happen at fixed steps to match the size of the brigs or something, but I don’t think that it is the best solution for those cases.)  
> Default texture:
> 
> ![witchtiled_defaulttiling0.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/e/8/e8b2c6909f889d6f4585635dbd98a67503a5bb69.jpeg)  
> Randomized:  
> ![witchtiled_randomtiling1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/7/e/7e5b0f45fac0c04e4f7708de5483fcc944ef7f0d.jpeg)  
> Debug views showing how the tiles are composed together:  
> ![witchtiled_debugtiling0.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/6/8/687b756e013ff940dcb6c0c9927b3963f3a20cb6.jpeg)  
> ![witchtiled_debugtiling1.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/3X/5/3/530d1e3b5ad570c0d29903cfacdcafd71e95d68a.jpeg)  
> Depending on the value you set for “tileBlendWeight” the influence between the tiling pattern against the textures height map can be changed with lower values leading to a stronger randomized effect, though it will also start to heavily weight towards the heigher areas in your height map. The other parameters should be easy to figure out especially if you utilize the debug view.  
> The function was written for version 4.22.0 ( Which finally has a RGBA output on texture samplers and I used it, so no idea if that is going to break in earlier Unreal versions).  
> If you want to try it, just copy the text in the “randomizedTiledSampling.txt” file into a new function (delete the default output node first).  
> An example project with a texture and an optimized material set up can be found here: [GitHub - WitchDev/RandomizedTilingMaterials](https://github.com/WitchDev/RandomizedTilingMaterials)  
> Edit: There is one connection going directly into “texcoord” which should be connected to the respective “function input” instead.

How we do this debug view in the final image?

[Next page](https://forums.unrealengine.com/t/randomized-tiling-function-eliminate-repeating-patterns-in-your-textures/124519.md?page=2)
