Rock Layers Shader - UE4 Materials 101 - Episode 21

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] in today's tutorial we're gonna take a look at how to use procedural noise to create geological rock formations the first thing that I want to do is give you a little bit of background for why I developed this technique I had an art director and he came to me and he said the environment artists are creating a whole bunch of rocks and what we'd like to do is jam all these rocks together to create unique rock formations we only want to create a few unique rock assets but then we want to be able to jam them together and randomly rotate them to create a lot of unique variety but the problem that we've been running into so far is that when we jam our rocks together they just look like a bunch of jumbled jam together rocks and they don't feel cohesive or United so is there something that you can do with a shader to make our randomly rotated rocks seem like they fit together in a cohesive structure and so I went away and I found this particular solution using geological strata and procedural noise so let's take a look at some reference footage and this is some footage that my son shot on his recent trip to Moab and what you can see in this video is that rock is arranged in layers and the layers build up from the bottom and each individual layer has its own unique color and characteristics and the layers kind of blend together and this is the characteristic that we're going to be trying to emulate in our shader as we use our procedural noise [Music] all right so let's jump right into unreal and see what we can do all right here we are in unreal and you can see we're taking a look at this texture map that I've called a geo gradient and I created this texture in Photoshop and you can see that it's it's just a really small texture so it's just this gradient that has these different colors and this is what I'm gonna be using to imitate the rock strata I'm gonna protect this gradient onto my rocks in world space using the Z world space coordinate okay let's so let's get started with our shader you can see that here is my gradient and I've got the RGB plugged into the base color and it's applied to the cylinder primitive here in my scene and this looks pretty basic so we're gonna be using procedural noise to improve the way that this looks right now I'm using UV coordinates to project the gradient onto my cylinder and that's not gonna work because if you'll remember I want to be able to take these rocks and rotate them in any direction and still have the geological strata projected and have it maintain its coherency so I need to project these in world space so the first thing that I need to do is add the world space position and this is what I'm going to use to project my gradient so I'm gonna use a component mask and I'm gonna take the B Channel or the Z world space position and I'm going to create I need to make an append node here and I'm going to use this as my V coordinate and then I'm just going to use 0.5 as my you coordinate so I'll put 0.5 and plug that into my append and now I can use this as my UVs this is going to project my texture in world space instead of in UV space okay now if i zoom in really close here you can see that it is projecting but it's at the wrong scale so the next thing that I need to do is multiply my my B component here the the Z world space by a small number to adjust it so let's add a multiply and in this case I'm going to multiply it by a constant a value of 0.005 just to scale it down to the right size and let's see what we get great so it looks pretty similar to the way that it looked in UV space however now if I rotate my object around the strata will maintain their horizontal relationship regardless of how I how I rotate this object because it's projected in a world space okay so I'm just gonna clean up my graph a little bit before I go on and now the next thing that we need to do is start introducing our noise so I'm gonna lay down our noise value and I just want to take the noise and add it to the world space Z and see what happens Oh before I do that I'm gonna set my levels on the noise too too just because I don't need a whole lot of detail in the noise and in order to make the noise really fast and cheap to compute I'm gonna set it to fast gradient 3d texture and now if I just take my noise and I add it to this Z coordinate here let's see what happens there ah so so what I'm doing is I'm adjusting the Z coordinate up or down depending on how bright or dark my nose is and the adjustment that's taking place is so powerful right now that it's just making my noise this crazy mess so I need to tone it down a little bit so I'm gonna take my noise and before I add it to my UV coordinates I'm gonna multiply it by a small number as well just like I did up here and in this case I'm gonna multiply it by a constant of 0.05 and then we'll use that to tone it down and take a look and see what we get alright now you can see I'm getting some nice results the noise is broken up and it's giving this really neat impression like we have various layers of rock that are mixing with each other but I think the mixing is still kind of at the wrong scale and so what I'm going to do is I'm gonna take my world space position pass it into my position socket here now this is happening by default I don't have my world space position connected here but if I did it would look the same because by default the noise node takes world space position into this pin here but I want to adjust it a little bit so I'm gonna take my world space position and I'm gonna add a multiply and I'm doing this just so that I can control the scale of my noise and I'm gonna add another constant here and I'm gonna multiply this by 0.03 just to scale my noise down a little bit and then I'm gonna pass that into the position let's take a look and see what we get okay you can see I'm getting this really interesting pattern I think there's one more thing that I want to try oh actually I want my scale to be zero point three not zero point zero three it's a little bit too small but you can see how I can use this value and get all kinds of different effects so if I set it to zero point three I believe that now I'm gonna get the effect that I'm looking for yeah so I've got my nice striations here and you can see them how my gradients are mixing with each other and what this is gonna allow me to do is to take my rock and rotate it in any direction and my color gradient is going to be blending using this procedural noise but it's going to be projecting in this Z direction so that no matter which way I rotate my rocks they're always going to be feeling cohesive because they have this geological strata pattern projected on them now you can take this technique the same idea and expand on it for example you might unwrap your rocks and create textures for them in UV space but then blend that texture together with the texture that we're creating with this technique to kind of get a best of both worlds so if you have a nice rock material but then you want to project this geological strata pattern on top then you can get something that has a nice unwrapped rock look but it also has the cohesiveness that this technique gives it okay let's go ahead and take a look at a real world example and see what this looks like actually applied to rocks alright so you can see in this video that I've got this really interesting looking rock and I only have a single rock asset but as I add additional instances of the asset and rotate them around I can jam these rocks together and they still feel like a single cohesive unit because I'm projecting this strata pattern on them in world space and I can rotate them around randomly and stick them together in different angles and create all kinds of like infinite variety of rock assets this is a really cool technique because it allows you to get away with creating just a few unique rock assets but achieving an infinite number and complexity of rock assets because we're projecting on these assets in world space using this procedural noise strata projection it's a really cool technique and I hope that you can use it to create some really nice rocks of your own and save you from having to hand create hundreds of uni cross rock assets you can get individual lots of individual rock assets by just combining a few together well that's our video tutorial for this week I hope that you enjoyed it and that you subscribe to the channel and I'll see you in next week's tutorial [Music]
Info
Channel: Ben Cloward
Views: 6,428
Rating: undefined out of 5
Keywords: UE4, Unreal, Unreal Engine, shader, material, material editor, game development, real-time, tutorial, training, Unity, graphics, 3d, GPU, tech art, computer graphics, fundamentals, basics, beginning, learning, perlin noise, perlin, procedural noise, fractal, ocataves, rocks, rock material, geologic strata, rock layers
Id: cGmWa-gETzU
Channel Id: undefined
Length: 12min 43sec (763 seconds)
Published: Thu Apr 09 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.