Thanks to this marketplace thread: 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.
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:
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
Edit: There is one connection going directly into “texcoord” which should be connected to the respective “function input” instead.
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.
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.
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!
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!
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.