Announcement

Collapse
No announcement yet.

Randomized tiling function, eliminate repeating patterns in your textures!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [ASSETS] Randomized tiling function, eliminate repeating patterns in your textures!

    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:
    Click image for larger version  Name:	witchtiled_defaulttiling0.jpg Views:	1 Size:	170.4 KB ID:	1603515
    Randomized:
    Click image for larger version  Name:	witchtiled_randomtiling1.jpg Views:	1 Size:	162.2 KB ID:	1603517
    Debug views showing how the tiles are composed together:
    Click image for larger version  Name:	witchtiled_debugtiling0.jpg Views:	1 Size:	173.5 KB ID:	1603514
    Click image for larger version  Name:	witchtiled_debugtiling1.jpg Views:	1 Size:	405.2 KB ID:	1603516
    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: https://github.com/WitchDev/RandomizedTilingMaterials
    Edit: There is one connection going directly into "texcoord" which should be connected to the respective "function input" instead.
    Attached Files
    Last edited by witch-dev; 04-25-2019, 02:11 PM.
    Randomized tiling function to eliminate repeating patterns in textures.

    #2
    This looks insane! Thanks!
    | QuinnVR | Portfolio | Twitter |

    Comment


      #3
      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 https://blueprintue.com/blueprint/l3n_xi28/

      I wonder if this can be used in an ocean material or other applications.
      Last edited by Gallonmate; 04-05-2019, 01:24 PM.

      Comment


        #4
        Originally posted by Gallonmate View Post
        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 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.
        Randomized tiling function to eliminate repeating patterns in textures.

        Comment


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

          Comment


            #6
            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!

            Comment


              #7
              Looks great! Now to make it world aligned.

              Comment


                #8
                Originally posted by Magneto View Post
                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.
                Storyteller - An immersive VR audiobook player

                Dungeon Survival - WIP First person dungeon crawler with a focus on survival and environmental gameplay ala roguelikes

                Comment


                  #9
                  Originally posted by n00854180t View Post

                  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!

                  Comment


                    #10
                    Originally posted by Magneto View Post

                    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).
                    Randomized tiling function to eliminate repeating patterns in textures.

                    Comment


                      #11
                      Originally posted by witch-dev View Post

                      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.

                      Comment


                        #12
                        Originally posted by witch-dev View Post

                        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!

                        Comment


                          #13
                          I've uploaded an example project: https://github.com/WitchDev/RandomizedTilingMaterials
                          Randomized tiling function to eliminate repeating patterns in textures.

                          Comment


                            #14
                            Big Thanks for example!

                            Comment


                              #15
                              Originally posted by witch-dev View Post
                              Thanks for this!

                              Comment

                              Working...
                              X