Dynamically Scale and Randomize Textures | Unreal Engine 5

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone today I'm going to be showing you how to tweak UVS to get some interesting results and allow you to create worlds a lot easier one of them being all of these objects have the exact same texture on them but as you can see the scale of the texture is the same in all of them in terms of world's highs and that is not done by triplanar as done by scaling the texture relative to the object so you're able to keep things correct in world scale and then not need to worry about something being too large or too small and as you can see right here on these rocks this is the exact same Rock but the textures are all offset randomly so that way you can use the same texture on everything and it will not read the same on every single Rock obviously you could still tell something is repeating if you have some kind of unique thing like this orange stain it is just moving around but this gives you a nice breakup and allows you to create things much easier than if you would with a very repetitive of object let's show you how it's done as always here we are in a brand new project this is 5.2 but this is possible in any unreal 5 version and possibly unreal 4 as well I just have not tested it so let's get started just go ahead and create a new material I'm going to call it m underscore UV demo for myself I'll go ahead and open it up and here let's go ahead and just create a texture sample parameter and I'm going to call this base color for myself this is so we can have something to visualize and to actually pipe into our UVS so to get started if you hold down U and left click you get the texture coordinates right and so if we plug this in and then make a material instance of this we can now swap out the base color in here right and if I grab one of the mega scans textures I downloaded and plug in the base color and we have the our base color so already if I brought in this rock and we replace the texture on it with the material right so this is our base but of course this scales with the object and we want to maintain the scale of the texture so to do this is actually very simple before this input for the texture coordinate you want to get object scale so once you have the object scale I'm going to add up all of these all of the act different axes so I'm going to add X and Y and then I'm going to add Z to it so we have all three values added up into one and then I'm going to divide it all by three the reason I'm doing this is because I want to get the average of all of the scales that we do so if you scale it only in one axis it'll still increase the texture tiling we can now go ahead and multiply it fire object scale and then plug it in immediately you could see if I scale this up or down it automatically is scaling the texture with it so now we're able to get very easy control of how large we want all of our rocks to be so as you can see this detail on this large rock is the same scale as this detail in this rock same detail as in this rock so this allows you to really easily use one object with a tiling texture and make a lot of really nice variation without needing to worry about texture resolution scaling up or scaling down too high so let's go ahead and actually also plug in the roughness to get a nice demo here and I'll also plug in a normal there you go so now already this is you could see this has been made of different rocks but it really feels like it all Blends together and I can real quick just go and adjust anything have it intersecting have one that is absolutely massive maybe in the back and it all will read together because the scale of the texture is correct for everything and this is not a trip planner so it's far more efficient but of course when you have even this rock right and you have the right side by side by side well you can tell it's the same Rock because right it's the exact same highlight in the exact same position so let's go ahead and modify our UVS one more time to give it the slight variation between the objects for that what I'm going to do is grab object position in World space and we're going to multiply it by random values and the reason for that is if I do object position if I move each one of these on a grid by 10 then it will have the same value each time but if I multiply it by three random values for example two and just match the keyboard and then plug this in this will randomly offset all of these values so it should break up that monotony so once we have that we go ahead and break float3 so we want to get the individual axes because we need to use this inside of UVS which are a float2 and this is a float three so for that we're going to go ahead and add the red and the blue Channel and we're going to add the green on the blue channel so you can think of these this might say RGB but think of them X Y and Z Z being up so it will offset the X if it moves up or down and along the x-axis and I'll adjust the Y if it moves up and down or along the y axis then we go ahead and use the Frac node to only get the fraction of it so the Frac does basically it it cuts off any number any whole number and only leaves the decimal points which is what we want if you offset this entire thing by one 1 2 4 8 doesn't matter if it's a whole number it's effectively looping itself so we only care about the fraction after that we go ahead and append the two and we add it onto our setup here and if I hit apply immediately you could see these have now offset so if I slightly move these around you can see how it's randomly placing these now one other thing I like to do this is what I found personally is also multiply this entire thing by value that way it moves a slightly different pace than it does currently because if I turn off snapping and I move this you can see it is it's doing it but you can adjust the speed by just changing the scale here if I change this to let's say 2.5 the speed for the same distance that it moves can be adjusted there so this is not necessary but if you want to adjust it you can but now we have things being broken up quite nicely and it is fully randomized so this rock does not look like this rock this does not look like this rock does not look like this rock so we're able to have nice variation with one texture with one object and unless you start looking at the actual shape that is repeating right because the outline of the object doesn't change this now gives you all the nice variations you want and you can go in place things around scale them however you'd like and it'll all work together beautifully nice and quick for this one hope you guys enjoyed if you did consider hitting the like button subscribing and I'll see you guys next time take care bye
Info
Channel: Procedural Minds
Views: 7,379
Rating: undefined out of 5
Keywords:
Id: WlwfA4wd338
Channel Id: undefined
Length: 7min 20sec (440 seconds)
Published: Sun Sep 17 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.