Unreal Engine 5 : How to REMOVE/HIDE Texture REPETITION with Natural Variations in UE5 Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Texture repetition or Texture tiling is a pretty  common thing that you come across when you   are building your landscape in Unreal engine. Hello and Welcome to this video, Today we are   going to take a look at all those methods which we  can use to create a material which does not repeat   itself and we get some natural looking textures. We'll start with this basic texture and work   our way up to this material which  has this natural color variation. T create this, Let's create a material and rename  it as LM_Test. LM stands for landscape material. So when you create your material it  looks like this. It's not different from   any other material that you create so you  don't have to do any additional thing to   create a material for our landscape. So  let's start with bringing our textures in.  So we'll take the texture sample  and put our grass textures in it.   All of the textures that I'll  be using in this videos are   from the Megascans which is  inbuilt in Unreal engine 5. This is the Grass texture  that we'll be using for this.   So we'll go to the Megascans folder and  in surface we'll look for the mossy grass. And this is the Grass texture  that we'll be using for this. So with the new Megascans in Unreal Engine  5, You'll get three textures. The first is   diffuse texture, normal texture and ORD. So we'll bring them in in our material. So The first goes in the base color, then  normal and this ORD stands for occlusion,   roughness and displacement. So the red  color channel is our ambient occlusion,   the green is our roughness and the blue is  displacement, which we do not need for this one.  So we'll leave it at that and by  simply connecting them to our material   and changing our landscape material to the  one that we created just now, we get this.  So we get this pretty shiny material,  This is from our specular light   so we'll put the specular to zero for now. And as you can se, You get grid type  structures and the texture is repeating a lot.   We will use landscape coordinate so this is used  for UV textures. We apply this directly to all of   our texture samples and if we divide it by any  scalar value, let's call it tiling and put a   input 3 by default. And now we can control our  landscape coordinate with that scalar value. Now if we increase it to 10, You can see  that the textures are bigger than before   and if we increase it further then  they will keep increasing their size.   So ideally what you would want is  anything which is closer to where   you are looking to be smaller and anything  that is far far away that can be bigger.  To have good UVs you would need to know  the overall resolution of our landscape. So when you are creating your landscape, There is a section called overall resolution  and here you can see it is 4033 by 4033.   We will remember this value and  put it in the mapping scale of our   landscape coordinate which will apply the  texture on our whole terrain without any tiling.   So if we take a look at what  the landscape looks like,  This is our landscape and the texture that we  applied is applied on this exactly one time. So if we imagine this as the default scale, So with tiling 1 is the smallest value of our  textures and if we increase it we'll get more   and more texture repeating. The higher I  go the more the texture will be repeating. We would right click and click play from  here so our mannequin is right here. So you can see how much our texture is  scaled with respect to our mannequin. And now, We can adjust the tiling value so  that we can see which scale looks realistic.  Now coming to our first method to reduce the  texture repetition, We would do a distance blend,   So what distance blend would mean is that the  textures that are close to us would be smaller and   the textures that are far away would be larger. So we will take our diffuse texture, duplicate it.  So for the near tiling, We will  multiply our UV, 1000 by default.  We would duplicate it and  that would be our for tiling   and then we multiply that by our UVs and put it  in the second texture sample that we duplicated.   So the first one is the tiling scale  for the textures that are close to us  And the second one is a larger  texture for far away points. This is a inbuilt material  function and it needs some outputs.  First one is the fade length, so we would  create a scalar and call it Fade length. And plug it in. Then We would  set the default value as 2000.  And then we would duplicate  this and set the fade offset.  So now this camera depth field will  give us the values that we need to blend   so we would put a linear interpolate. So we would put A as the near tiling textures and   in B we will put the far tiling and as the alpha  will put the camera depth and putting in the base, With linear interpolate depending on the  value of alpha we get A and B values.  So if the alpha is 0 somewhere   then we would get the A value and if  the alpha is 1 then we would get B. Now let's change the Far tiling  so we can see it clearly. So by default we put fade length and fade off  set as 2000 so it means that after the 2000   distance there is another 2000 in which our  first tiling and second tiling are blending   so you can see it clearly right  here our textures are blending   depending on the tiling, we can change  the tiling value and see how it affects. so you can see most of our tiling is gone we  can still see some of the tiling close to us   you can see here this texture  is repeating again and again.  So this is all about distance blending since  we will be using this landscape coordinate for   all of our UVs let's put it in a comment box  and name it UV so that it's easier to spot. Similarly we will put the  distance blend right here.  Again let's change the color, now we will be using  this UV and distance blend for all of our results.  Now to keep our material clean and not  have all those webs where we don't know   which pipe is going where and it's all a  big mess we would use material function.   So to create a new material function we  would right click go to material and textures   and click material function and we  would name it MF_Test_DistanceBlend. So we will use this material function  to blend it based on the distance.  And with the material function we can have as many   number of inputs as we want  and similar for the outputs.  If we right click and type function input  we get input and if you type function output   we get the output. Now let's rename it call it   height and let's change the input, input UV now we  can duplicate the input and call it input texture.  Now we have two input and two output so to use  our material function in our landscape material   we would just drag and drop it in our material. Now we have the input and output that we named   in that material function now if you  notice for the outputs we have high first   and the result is the second we can  change the order of any input or output.  For that we would change the soft priority  so the less the number we put here   the first priority it is even so if we type 2  here then the height should show after the result. Now this is our custom created material function  we also have some inbuilt engine created material   functions such as this camera depth fade. It's getting the distance between camera   position and the absolute work position  and it's doing a bunch of calculations   but we'll be using our own simple distance  blending which is not that complex and only   uses camera position and the word position. Now let's create our distance blend which   is blending our two textures  with the linear interpolate. so basically it means that we'll be replacing all  this with our distance blend material function,  So for that let's take a texture sample  so sometimes when you are creating your   landscape material there will be times when  you are getting some artifacts like some of   your textures are not showing up, there are some  spots where your default material will show.  So to fix that you would change your sample  source from textured asset to shared warp.  Now we'll duplicate this texture sample and  use that for our UVs so we'll take the UV input   and then multiply it twice and  multiply one with the near tiling. And another with the Far Tiling. Let me change the default values. For near tiling, We'll choose 1000 and   for far tiling, let's say 100. Now put that in our UVs   and now let's interpolate them with the lerp. So we'll put the near tiling in A and the   far tiling in B. And for the alpha,   we'll use the distance blending value. For that let's make a input, we'll   take this texture input and rename it. By default it is a vector3 input type,   so for alpha we only need a scalar value that goes  from zero to one so we'll change it to scalar.  And put this as the the alpha, So whatever we  put in our distance blend output that will be   connected directly to the alpha. Now let's connect this to our result,   we don't need this output height this will just  to show you that we can get multiple outputs.  And we get a error so this one tells us that  we are missing input textures that is because   the texture samples are empty. We are not using  any texture, so we will give our texture input. So we use another function input to input in our  texture and change the input type to texture 2d   and call it in texture and now let's connect that  as the texture and now we get another error which   is saying that it's missing a preview connection  it needs something for our texture to calculate   things so we'll put a default texture object and  connect it so now that error is gone and we get   another error which is saying that coercion  failed trying to convert float 3 to float 2. and that is because we did not change the  uv input type we have put it as vector3   but for uv coordinates we only need  two xy so we will change it to vector2   and now the error is gone and just to make  sure that we get only two outputs we'll take   a component mask and choose the red and  green channel so it's only taking the x   and y from our uv this is not necessary to do  since we change it from vector 3 to vector 2. and if we take a look at the distance  blend we get all those inputs let's take our tiling and make it the input   so we will put a function input and call it  near tile and change the input type to scalar and then duplicate it and call it for tiling and then let's put it as multiply  and for the preview values we'll   put the scalar values that we created before and if you choose any input and click use  preview value as default this one right   here then it will use whatever preview value  that you are supplying is the default value   so if nothing is connected to it then it will  take the preview value and if we connect any   values in our material function then it will  overwrite that value connect it to our base   color so it's saying we are missing those  inputs so if we put distance blend and uvs   all of these textures were not using  any default value and we had to   supply any values otherwise they would be  empty so that's why we were getting the error and you're texting so we'll  take the texture object for   that and put it in then the error went away for the tiling if we undo it we'll see that we  get errors saying that these two needs input   but if we are using the preview value as the  default value we don't necessarily need to   supply those values we'll be using those values  as the default and the error should go away   so this one is especially useful because so most  of our taxes we are using mega scans and their   taxes are two meter by two meter or you can  just say that they are the same scale so the   same tiling will work for all of them so that is  the partial linear tiling which we are using in   the material function that will change for all of  the materials that we are using in our landscape   but if we want finite control over any texture  you can put a scale level and connect it to   that material functions it will override  that value and that scalar will control   the value for only that textures now you can see  inputs and we want to sort them out so that our   is it at the top and the distance length is  at the bottom so we'll take uv and this is   priority 0 which means it it is given higher  priority and i will change our texture to   the priority after that so let's say 3 so we'll  use a higher number for all of the other inputs   so what actually we are using three and for  near tiling power tiling in distance plane   you can also use one two three four but  then if you have to make another input   which you wanted let's say right after the texture  so you will put priority 2 in that but that value   is already used paneer tiling so you'll change  the tiling for near telomeres 3 and file tiling   4 5 but if you have already given a gap in  between then you can just put that as four and   linear tiling is already higher number it's just  easier to make changes like this 12 6 9 and 12. now if we save you can see that our  inputs are sorted according to that values   now we don't need these we'll delete one and change this right click and  convert to texture object so this is the texture   that we'll be using so we'll just connect it  to the material function that we just created   now this is for our base color and now another one of the reason why we should  prefer material function because now we can   duplicate and use it for our normal so you can  just connect it directly into the normal and   should make all of the connections so let's create  a texture object and put uv distance blend our   texture and we are good to go now we can use the  same material function as many times as you want   and make our graph cleaner and easier to  navigate we'll do the same with the over detector and the only thing that we need to change here  is put a component mask remember in ord we had   occlusion roughness and displacement occlusion  is in red so for our first component mask we'll   take only the red channel roughness was in  green so for the second will we'll choose   green and connect the first one to  occlusion and second to roughness   so this is our textured distance blending will use  our own distance blend which is far less complex   so in camera depth if you see it's using  camera position and the word position so   you will just copy these two and paste  them here let me just make this figure   you can get the same from searching like  word position and command camera position now let's get the distance between them surfaces   distance and scroll a little under  utility will find this distance so this distance can get the distance between  any two point color or positions so distance we   are getting the distance between word position  and camera position it's time for some math so amazing we are here so this is where our  camera is and we are looking at this point   on our landscape so the first thing we did was  get the distance between the absolute position   and the camera position which is this and now  we subtract any value from it that would be our   offset so if we subtract this value we only get  this distance so this is the fade offset that we   were getting from the camera depth fade and  for the rest of the stuff which is left here   if we divide it by any values so let's say  this distance is hundred if we divide hundred   by hundred we get one which means the whole  fraction of this length if we multiply it by   let's say 0.4 we get the 40 percent of this length so whatever we divide it by  would be the distance at which   our textures are blending or  you could say the fade length   so if you come back to unreal and from this  distance we subtract that would be our fade offset and then we divide that would be our fate length  now let's delete those connection from there and now let's put saturate so what saturate will  do is it will slam the values between 0 and 1   and it does not take any processing time and then  you would do a 1 minus x if you remember the graph   from before all of the values that were subtracted  and divided that was away from our camera so if we   subtract it from 1 minus x then we'll get  the same distance but close to the camera now just to make sure that it is a scalar value  we'll take a component mask and use the red as   the channel so this is our distance blend this  we are doing because with the word position and   camera position those are vector values and  with mask we are getting only scalar value   now let's redo the connections  and then organize it since we were using one minus x we have to change  some of the connections in our distance blend   so we would go to our material function that  we created before and just change the input a   and b so now e is the far tiling and b is the  near tiling now let's save it and come back   now we are getting the same distance blend  but with a far less complex distance blend   and make sure that all of the connections  are the same and take a look at our landscape   and now to get even less styling  we would take another grass texture   and blend that with the original one that we have  with the use of material function it is very easy   you just have to duplicate all of that and make  the connection for the uv and distance blend and   to blend them we would need material attributes  like base color in all of them so we would right   click and click make material attributes and  make those connections of base color normal   and roughness let's not do that for the ambient  occlusion since we only need to see our tiling distance blend now let's take a look at the other  textures that we are going to use   so if we go to your mega scan folder so  this is the texture that we are blending   and let's take a look at our original and  they are already quite similar from the start we take all those three graphs by default  it converts them to texture samples so we   convert them to texture object or we can directly  right click texture object and then put your   texture right here and let's delete the one that  we're using before and remake those connections and now we have two different  materials and now to blend these two   we are going to use matte layer blend simple this  one is also another inbuilt material function so   it's just easier because it takes the material  attribute as the input the way we are using this   and we will put our graph a in base  color and grasp b as the top color   this is the same as the a and b input from  our love and this is the alpha that is used   from the love it's doing nothing more than taking  like say base color from a base color from b and   using a left with the alpha that we provide and  then we will create the alpha 4 material blend   first let's connect it to our material so first we  will append a break material attribute node here   and then we can disconnect those connections and  connect them with the material here the base color   roughness and then the normal now let's come back  to the alpha for the alpha let's use a texture so this is a inbuilt purlin which is in the  starter content since this is alpha it will   need a scalar value so we'll use the red  channel as the alpha and connect the uvs and save it by default if you remember that the  landscape coordinate will put this purlin as a   single texture on all of our terrain now if we  take a look at this and these two material are   blending it's actually really hard to tell  so if you see in the parliament right here   the difference between the white and the dark is  not much so we'll add a contrast and use a scalar   parameter let's call it matte blend contrast  let's change the default value to point one so here in the dark areas this is the second  texture that we are using and here is the first   action really really hard to tell the difference  between two since these two were similar   now this is simple purlin but you can also use  a splat map here so that you have more options   so if you were using this flat map you  would use a component mask and we are   using only the red channel here and  let's send the texture to a splat map this one has the red green and blue channel  so the advantage of using a splat map or a   normal purlin would be that if you want  let's say a dense mix then you use the   red channel if you want a sparse mix then  you would use the blue channel so that's   why we are using a component mask here and we  can right click and convert it to parameters   in the material instance we can easily change the  parameter value and put the contrast after that now you can clearly see the difference  the one that is light in color this is our   texture a and the one that is dark is our  texture b we can do all those brightness   contrast and saturation adjustment right after  here for both of both of them so that they blend   better but we are only going for the tiling  so let's keep it simple for this tutorial   and now let's create another material function for  the alpha name it mf underscore matte blend alpha   now we open this and copy these from here and put them here now let's make input for our use vectors  and change the input type to vector 2 and put it in the uv and since this is a splat  map which is created in external application but   you would have let's see a purlin to combine those   so you may want to have some tiling for your  purlin so for that you would just multiply   that by scalar value quantile but we  are not going to do it for this one and now let's make another input for our blend  contrast and make it scalar and connect it there and use that as a preview by  default it will use point one and let's make another input for the  material texture we'll duplicate the uv now let's change the sword priority  so you will want to ue at the top browse to where this material function  is take it and drag drop in our landscape it is giving error because it needs the uv and  the texture let's bring a texture object here   and connect it to texture and let's just  fold that variation split map that we have   now if you were to change the contrast  from point one to let's say one   you can see the contrast of our texture  changing here let's just leave it at one for now so you can see that there is no tiling in close  to us then there is no tiling photos but there is   a little bit of tiling in the middle distances so  we would solve that with the texture variations so we would want to add texture  variation after all of this is done   so that it is applied the  same for both of the texture so if you go to starter contact materials and  the more not the most the grass this is this   startup material and you see that there is a micro  variation texture here we would simply just copy   it from there and paste it here so now we will  take a linear interpolate and put this as alpha   the material atp does not work with love  that's why we were using matlab simple before   to blend our materials so for that from here  we would connect a get material a little bit   and click plus and choose base color  here and you can use the base color   as the b output and for the a we  would multiply that base color now we are using a vector 3 so if you press 3 on  your keyboard and left click then it will put a   vector3 for you you can right click and  convert it as a parameter so that you can   easily change in your material instance and  now let's rename it as micro variation color   let's choose a value of let's say  0.5 and just multiply it by that so   it will darken in those areas that  were created by the micro textures   and now let's connect it again you cannot  do that with your base another set material   we take all of the material  attributes from before and then   choose the base color so it will only overwrite  the base color so if you connect it click save and as you can see here you get  all of the small texture variations   and now we do not have any tiling  anywhere and it's looking pretty good if we click play from here let's move around a bit and the tiling is solved now you can also change the color from here  so let's say you give it a dead grass color so   all of those will be converted to a  colored input you can amplify this further   but that will just look unnatural  and we don't want those colors so now let's name it as micro texture  and now you can see that in the starting   grasp we're using this texture coordinate  but we don't want that so we just delete   it and use our own uvs so we take word  position and then connect it to our use   so before that let's create a divide and for  the divide value we would use a scalar value so   let's call it micro variation tiling and give it a  default value so before that let's solve our error   which is saying float 3 is converting to flood  2. we got the same error earlier and it's because   absolute word position gives us a vector but for  uvs you only need two values x and y so you take   a component mask and only use red green for that  and now let's change the d4 value for this as 9000 now we did our own use because we want to  change the tiling for our micro variation   okay if we change it 100 we get  even smaller micro variation so   you can control the size of the  micro variation from right here now you can see that we get micro variation close  to us we are also getting some of them in the far   distances which is looking really really ugly  so we would do a distance blending for them   so you come here and take another distance  blending as the alpha and remember since we were   using one minus x for our distance blending so we  would put quartiling in a and near tiling in b so   we'll connect it as b and for a we would connect  the base color which was coming from before   and use that as a base color and now if you  look at that we only get those micro variation   close to the camera and so if you go far no  micro variation and then boom micro variation   maybe now let's make a comment  box here let's call it mate blend move this out of it now we'll come the most  amazing part which is the macro variation   which will take our material and give it  realistic color variations which we see in nature   for that we will take a texture sample let's  connect the use and for this texture we   would use this graph structure this is again  created in gaia so it's based on the natural   flow deposit all of that so for the guy uses it's  basically just the output from the texture node and then just like this flat map where we used in  the rgb channels we would take a component mask   and then take the red channel for now and let's  convert it to parameter so if you want to change   the texture from there you can easily change the  mask so you name it macro variation component mask let's call it blend oil blend our layer  just simply blends it as a overlay so we put   base color as our base and the  macro variation is our blender now if you take a look at this let me zoom  out so this is the texture which will be   applying our macro variation it's not complete  because it's only giving us the black and white   values for now this is just to see what is doing  so right here these are the micro variations   let's turn them off for now  so use base color as the base so now you can see you have these areas where  it's really dark and in the same texture you   get some of the areas which are brighter and  then in the cavities there are again dark   and then there are also some  variations depending on flow and such   so if you see the before and after  this is without the micro variations   and if we connect the blended one so this is the  micro variation now let's change the color for the   variation with this texture if you preview this  so now since we are only using a channel from it   it is only black and white value so now now let's  delete the uv so you can easily see it on this   sphere right here as you can see here and we  can put a color here with another texture sample   so this is the color gradient  which we'll be using for our grass   and for the guy users this is the set map  that we get now if you put that texture here   and start putting this node now you can see that  this is giving you the colors based on the setmap   so now as you can see that those  black white values from before   are now colored with the texture that we are  using now now let's use the rgb as the blend   and take a look at how our landscape is looking this is not the result what i wanted and  something is wrong we forgot to plug in the uvs   so after plugging in the use and look at that so  we have this amazing color variation based on the   flows and the cavities and it  looks much more natural than before   in these light and dark values those were from  the color difference from our actual textures it's bothering me so let's make some adjustment  to our texture so i'll put a d situation here   actually let's just multiply  because we only want to darken it   we'll put a scalar value  here let's name it darken a and just save it and now let's  see yeah much better than before   now let's adjust the values so both  of the brightness are much closer so with 0.6 that took care of it all   now you can see amazing natural textures  and there is no texture repeating anywhere for guys this is just the set map now for the  non gaia users this is only a color gradient   so you can make your own so if you  take a look at this color curve   this is something i created  and it has some color variation so to get this you rightly go in miscellaneous  and there is the curve and the curve atlas   so this is the curve and this is the curvature  color curve has all of our colors and the atlas   can hold as many color curves as you want so  if you go to the gradient curves and press   plus you'll see all of your colors listed here  so let's say we here we are using these two so if you come to our landscape  and click curve atlas parameter   there you have it so first you will  have to choose the atlas here and after   the atlas you can choose the curves that are in  that atlas so for us it is the linear color curve and then you will have to multiply it  with the texture that was created before   and put that value in blend   and if you save it and take a look at it so this  is the result we get not exactly natural but you   can get some pretty results after adjusting the  color values in your car i'll delete that for now   or you can use any color gradient created in any  external software such as photoshop let's save it and here is our natural variations the texture that i was using were not  made for this landscape but they are   still looking pretty good and now let's take a  look at the landscape that they were made for so here is the landscape that they were  made for and as you can see that in the   four values there is some discoloration and the  color cavities and it's matching the exact natural   formations that happen and we get our amazing  material and hope this created things up above   the texture repetition i'll put some of those  variation textures down in the descriptions so   that you could use them in your projects thank you  for watching and i'll see you in the next video
Info
Channel: Klaus
Views: 93,722
Rating: undefined out of 5
Keywords: unreal engine, unreal engine 5, game development, tutorial, how to, landscape, gaea, klaus, klauslyf, texture, ue4, ue5, megascans, repition, tiling, variation, hide, avoid, remove, texture repition, free, unreal, bridge, unreal engine tutorial, texture tiling, landscape material, natural, realistic, ue4 texture repetition, unreal texture repeat, repeat, unreal texture tiling, rid, prevent, materials, making, creating, engine, textures, tile, texturing, variations, beginner, texture repetition, unreal tutorial
Id: j1AekcZeOKc
Channel Id: undefined
Length: 41min 54sec (2514 seconds)
Published: Tue Feb 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.