Shaders & Materials:

Anti-Tiling in Unreal Engine


While working on my Snow Shader, it became clear that tiling would be an issue with snow because unlike other textures like dirt and grass which can be obscured and broken up by additional foliage, snowy landscapes often have vast patches of uninterrupted flat land — prime real estate for tiling.

The first solution I found was distance blending. Using the `Distance_Blend` node, you create a mask which can drive a transition between two different textures. 

This adjusted the scale of the textures based on their proximity to the player; unfortunately, this only created larger tiles rather than eliminating it — a blunt instrument that on it's own wasn't enough.

The next thing I tried was adding overlays. This involved adding mask textures which would reveal shifts in the hue, saturation, and brightness.

This was a nice improvement, but even using seamless textures I could still see areas of repetition on the uninterrupted landscape.

Before

After

Unsatisfied with rudimentary solutions, I needed a way to break up the texture further. What if I could add variations to the scale, rotation or swap between different textures altogether?

This brought me to experimenting with Material Functions. I created a network of functions each building on the abilities of the other:

1. Hash23:

Takes the object's UV coordinates as a Vec2 input and passes them through a series of obscure scalar values in order to produce a random noise output as a Vec3. This creates a random noise using the UVs.

2. TransformUVs:

Exposes parameters to offset, scale and rotate a set of input UV coordinates around a pivot point of your choice — this is where I fell in love with the `AppendMany` node for its ability to merge scalar parameters into a Vec2 or Vec3.

3. RandomTransformUVs:

Exposes inputs for the minimum and maximum values of the scale and rotation, and uses the Hash23 to lerp between the min and max values for added randomness. It also takes a separate noise texture as a random seed value which is helpful for reproducing the same effect. 

With this one simple trick (doctor's hate him), I've made a huge leap towards eliminating texture tiling.

However, this lead to some strange effects on the Normal map, where the rotated chunks of the normal appear to be lit from a different direction — for now, I've limited the amount of rotation to minimize this effect. There are also noticeable seams in the texture when using an image such as this cobblestone, but on something simpler like snow it's not noticeable. 

I intend to revisit this to see how I can solve these issues.

Even though not everything is running as perfectly as I would like with the Material Functions, the other techniques are effective at mitigating texture tiling and will be a great addition to my toolkit in Unreal Engine.


 

 

 

Using Format