Announcement

Collapse
No announcement yet.

Randomized tiling function, eliminate repeating patterns in your textures!

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

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

    Comment


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

      Comment


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

        Comment


          #19
          This is awesome! Thak you!!

          Comment


            #20
            Originally posted by witch-dev View Post
            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.
            How we do this debug view in the final image?

            Comment


              #21
              Originally posted by LucianoJacomeli View Post

              How we do this debug view in the final image?
              That wasn't possible in the version on GitHub, I've updated it with a new version that makes this possible, just toggle "showDebugColors" in the material.
              I've also updated the way tiles get rotated if "rotateTiles" is turned on, now each tile gets a random rotation (before it was fake rotations which were basically just mirroring the texture coordinates on different axis and it was always the same for each kind, so all green tiles used to be rotated 180 degrees for example).
              I also wanted to try using this with virtual textures, but the current implementation of virtual textures is not yet suitable for landscapes which is my main use case for this material.
              Randomized tiling function to eliminate repeating patterns in textures.

              Comment


                #22
                Originally posted by witch-dev View Post

                That wasn't possible in the version on GitHub, I've updated it with a new version that makes this possible, just toggle "showDebugColors" in the material.
                I've also updated the way tiles get rotated if "rotateTiles" is turned on, now each tile gets a random rotation (before it was fake rotations which were basically just mirroring the texture coordinates on different axis and it was always the same for each kind, so all green tiles used to be rotated 180 degrees for example).
                I also wanted to try using this with virtual textures, but the current implementation of virtual textures is not yet suitable for landscapes which is my main use case for this material.
                Thanks for reply, i've downloaded and open you updated in 4.23? Some things not open in my 4.22.3 version. I check the files and all they exist in the project but only 7 is in editor. I will download the 4.23.1 to verify.
                Click image for larger version

Name:	Sem-título.jpg
Views:	205
Size:	259.7 KB
ID:	1676846

                Comment


                  #23
                  Ah yes, I'm on 4.23 currently (built from source). I didn't realize that this could cause such issues. I hope you can open it and migrate it over to an older version if necessary. I'll make sure for future updates to pay more attention to that and update the readme file appropriately.
                  Randomized tiling function to eliminate repeating patterns in textures.

                  Comment


                    #24
                    How does this compare to the built-in texture_bombing node?


                    https://forums.unrealengine.com/deve...exture-bombing
                    https://developer.download.nvidia.co...gems_ch20.html
                    https://www.casualdistractiongames.com

                    Comment


                      #25
                      Originally posted by OptimisticMonkey View Post
                      How does this compare to the built-in texture_bombing node?
                      My material is much cheaper, as far as I can tell, even a single texture_bombing node in a material connected to only the base color output has already more instructions and texture lookups than my full material.
                      Randomized tiling function to eliminate repeating patterns in textures.

                      Comment


                        #26
                        Hi @witch-dev ,

                        Great material, thanks!

                        As feedback, it would be very interesting to have an option (static switch param) to use separate maps as normal, heightmap, base color, etc, instead of unified ones. Yesterday I (fastly) tried to add that options and to share it here, but I didn't found an easy way to do it and didn't get a perfect result, as I hadn't time to analize the whole logic of the material.
                        Last edited by Miguel1900; 10-23-2019, 09:28 AM.
                        RTX RayTracing easy global settings tweaker

                        Advanced HDRi background tool + 42 HDR images

                        Comment


                          #27
                          Originally posted by Miguel1900 View Post
                          Hi @witch-dev ,

                          Great material, thanks!

                          As feedback, it would be very interesting to have an option (static switch param) to use separate maps as normal, heightmap, base color, etc, instead of unified ones. Yesterday I (fastly) tried to add that options and to share it here, but I didn't found an easy way to do it and didn't get a perfect result, as I hadn't time to analize the whole logic of the material.
                          I understand that many might like that, but outside of prototyping purposes using it like that won't be very useful as each separate map would add three more texture fetches and that would quickly become very expensive.
                          But I have now added a new material that uses TAA for blending without a heightmap, so the transitions are just linear gradients. It still looks surprisingly good and with this adding another texture sampler will only add a single texture fetch. (for reference the height blending based material has with my two textures has 230 instructions and 6 texture samples, the TAA based material has 237 instructions and 3 texture samples (one of those is for temporal blending)). The new material can't be used with tessellation though.

                          Comparison screenshot left side is the old height based method, right is the new material. (The two ground planes are touching and I can't really tell anymore where one material starts and the other ends.)

                          Click image for larger version

Name:	witchdevTAAvsHeight.jpg
Views:	216
Size:	301.0 KB
ID:	1677744
                          Randomized tiling function to eliminate repeating patterns in textures.

                          Comment


                            #28
                            witch-dev , hi i don't know how to use Github so i've downloaded as .ZIP your project anyway... i put back in github https://github.com/LucianoJacomeli/RandomTiledRHAO in my version i add the RHAO version, my packed textures is: albedo, normal, mask = Roughness, Height, AO. Please test and check if is correct i think i've destroyed some parts, because my colors look strange. I only not understand why we need to put the mask texture weightmap in all texture.

                            Comment


                              #29
                              It looks fine to me, the colors look strange possibly because the skylights intensity was fairly high. You only messed up the output for the debug colors (you had the switch on your RHAO output and it should have been on your albedo), then I changed the normal map to use the normal map sampling mode. You aren't using a channel packed one, so you can just use Unreals standard that means the offsets around the rotation aren't needed and the function at the end which reconstructs the blue channel isn't needed either.
                              I've made a pull request to your GitHub project, it should merge without any issues.
                              Weight map works such that it multiplies the masks from the tiles with the height values from your textures and then calculates a weight for each of the 3 texture samples such that the total adds up to 1. With this weight, you can now multiply the 3 texture samples and add them together to get your final values.
                              In the next revision of this I'll make sure to include a version with a seperate normal map, but for anyone looking to use it with a standard normal map your version with my fixes should be a good starting point now.
                              Randomized tiling function to eliminate repeating patterns in textures.

                              Comment


                                #30
                                Material it is working alone, but why is so hard to use it in a landscape material? i don't know what it's causing D3DCompile Exception.

                                witch-dev Do you already try to use it in some landscape material?

                                Comment

                                Working...
                                X