Unity Shader Graph - How to make a Vertex Noise Displacement Shader

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
okay so hello and welcome back to another shader graph tutorial in this one we're going to be covering a simple vertex displacement shader the reason I've not been doing them very often recently is because I've kind of exhausted good shaders that you can make with shader graph as of yet because they obviously still not fully functional they've only decided vertex is place women and even then it's still quite limited I'm going to be showing how to make a kind of terrain tessellation so like making the ground bump here in other places it's basically like we're just offsetting the vertices to make the ground bumpy that's it if you have a a like the same sized mesh with more vertices then you can make it smoother than this I'm just using the plane that we get in unity but you can import something from blender or Maya or whatever obviously this is a simple tutorial but that's because as obvious as I said we can't do much more complicated stuff though with this you can you know take it and mess around with your own stuff and see what you can make yeah so I think that's it we're gonna get tutorial one thing to mention first is obviously as well as joining my discord server I also recommend joining this over disco server called programmers valley I'm gonna link in description I've been asked by one of the members kind of like a one-for-one advertising thing the reason I recommend joining is because they have more channels with more languages and more people that know the languages so you are if you need help this is actually a very good place to get help if you obviously want programming help or just to learn a particular language on here get help or advice you know there are plenty of people who know what they're on about and it's very active server like there's always people talking it all the time obviously if you join they'll be more people in it and so on so you know there's no harm in joining this whole server I can't beg you to join but you know I'm asking you to join so I hope you take up the opportunity but anyway let me just sort something out let me get the screen right ok so we're gonna make this I'll also show how to give like here I've just got X&Y offset which doesn't really mean anything yet they're not they're not linked up but when I make it I'll I'll link them up so let's just create a new material for the video so let's call it I can't be naming them like anything particular and we're going to create a new PBR Tschida I'll call it and like probably spelt that wrong but whatever now one thing to also note is that I'm using the same unity project that I did the video on like how to set up the version with the position node on here I haven't tweet anything over yet I haven't fixed this little like missing folk yeah I mean that's just me being silly but it still works properly there's no problem with it it's a bit slower than you know normal and I'm also on the beta version of unity so if you try and follow along this video and it's not working for you just go back and check my other video on how to set up like shady graph with vertex displacement though I've heard from other people that now it's implemented in the package manager though don't quote me on that cuz I'm not actually sure if that's the case so let's get into it first of all what we're going to want to do is we want to change this position node I don't know wise I'm very lucky but it's fine so we've got a position node here which is you know per vector free XYZ which is the x y&z coordinates of the object so if we search position they would this also gives us the X Y Zed so if we put enter here then I really don't know why this is lagging but I'll just deal with it oh well I yeah it's fine so currently if we just do that literally nothing is going to change it's just the same what we want to do is we want to be able to you know manipulate the X Y or Z or whatever we want to manipulate now for this because we're making a ground kind of thing make him even up and down as you know up and down is the y axis we only want to change the Y value of this object so first of all let's just you change the preview to a plane so we get to see what we're looking at here's our plane let's zoom in there we go so let's also enlarge this I guess we want to be able to change the Y but not the X or Z so we'll use a split node which we can basically pass in a vector 3 or 4 or 1 or 2 basically and access the part in it so we use the RGB as an x y&z we want to keep the are the same and the be the same on here we want to change the G which is actually the y offset on the plane now when we put it back into our like ends node we need it to be back into a single like vector free thing so let's do that and then from here we want to go R to X B to Z so beat his head I don't know why it's a bit slower but maybe it's cuz it's the beta version and it's not stable or something but it still works so now as you see on our plane we have the x and z values and then why is your serie that's fine so if we save that yeah nothing's gonna be different it's just gonna be the same as always there we go now let's start making change so as I said we're going to be changing the Y so this is this value if I get the plane which was some reason has gone up here if I change this to 1 it moves up by 1 this is literally the Y position of the mesh and if we just put in a row value that means the whole mesh is going to go up by that value but we want to make an offset where we change of particular vertices and the way we like basically what this is doing is its setting all vertices to 1 or 1.5 so on this changes all vertices if we want to access different ones we have to pass in some form of data to tell it which ones you want to manipulate and why and one way you can do this is noise so basically noise black is 0 white is 1 and gray in between is all the values between 0 & 1 now this scale is very big so let's just put that down to like 50 it looks really blurry and messed up if we put this into the Y now and you wait a second you'll see that this now instantly offsets our mesh in a weird way and it's static it just stays the same now what it's basically doing is it's saying that we want the vertices on the white areas to go up and the black areas to go down and then the gray areas in between and this mesh only has a certain amount of vertices if you actually look to the mesh data you'll be able to see that if you went into blender and made a plane and you subdivided it so add many many many vertices you would see a smoother change on here but as you look now if we go flat on we can see that each of vertices we've got a vertice here if we look on the side you can see there's like one here then there's a one here it just happens to be flat as well then actually yeah because this is a simple noisy texture the values are either 1 or 0 so as you see this is 1 it's up this is 1 it's up this is 0 it's down so now we've got vertice up and down it draws a line this is an edge and that's why it's diagonal down then it so happens to go back up to 1 then it goes across again to 1 then it goes down to do oh wait no it actually just have in-betweens yeah we do have in between this okay so the gray bits might be 0.5 0.4 0.3 whatever whatever so this is telling it how we want to do that now let's say we want it to be animated or basically be able to change it we want to have some kind of offset so titling and offsets always useful and we'll plug that into the UV so now if we change the tiling or the offset it changes the noise we don't really want to change the offset so let's change the so we do want to change the tiling we do want to change the offset so like one two three you see it changes the mesh at the bottom so we want to change this with you know I have a time or parameters in the in the inspector now for the sake of this I'm gonna use time just so we can see it live but obviously you will probably want to use parameters to do it so let's take a multiply so that we can bring it down because otherwise it's gonna be really fast so well we'll bring it down what did I do when I tested I think yeah point oh five was pretty good so we've brought the time down and now we want to be able to offset it in the X or the Y with a noise texture you really won't know is this to be honest because it's so random that the X&Y isn't even like you don't really know what the X&Y even is because it's so randomized but if you were using anything more precise than and texture this is probably better to do so you should do this anyway in my opinion we'll take two multiplies so one do and we'll put them here I might need more space so I mean just move this out okay so we're gonna put the output into both multiplies one of them is going to be handling x one is going to be handling said now we're going to take in some vector one so we'll call this like X offset and we'll call the of 1y well actually technically Zed offset so I'll call it said offset because Y is up and down and then we'll take this one oh okay now I'm gonna take back what I said there so basically the reason I said x y&z in whatever so X is generally flat like left to right Zed is forwards and backwards and Y is up and down the thing is that's different about this is this x and y offset is not the offset of the vertices it's the offset of the noise so really it's kind of just like vertical and horizontal so I mean you know just to be accurate and you know like to teach people the right things we'll call this vert offsets like not vertice vertical so like you know focal and horizontal or is on that cowl now I'm going to I'm going to swap them around because we won a horizontal as X and in Y alright let's put this into it so now we can tweak the values of both of them and then we need to form them back into a vector two so put them back into a vector two and now that can go into the offset now if we go to save and I wait a second okay so now as you see here here's the plane and we can go into the material and we can change this value we can just drag it now that's weird oh yeah no it's not weird it's because I actually I did use time didn't I yeah actually this vertical and horizontal is only really relevant ways at the speed sorry yeah this is the speed okay so obviously yeah tweak these values to the speed you want it to move in a certain direction if you look in the actual shader if we put values in the one means it's going one down because it's on vertical so it's up and down if I put ten it's gonna go you know ten times the speed down and then ops you can go up to 100,000 it starts going a bit hectic a bit crazy and inspector it's just the same you know you can change it to note to tell the speed in a certain direction now technically with 1:1 it means it's going it's going diagonally whichever diagonal way is but it's really hard to tell because as I said it's a noise texture and it is hard to tell but the only thing I really have to show you now obviously this is how you move different vertices separately and you know you might have learned something or over about vertices you might also want to change the height so it's like less bumpy or more bumpy so the way we do this is over here the simple noise before we actually plug it into the why since noise is only between 0 & 1 you might want to you know you might want to multiply your values well no you it depends if you want it to go to the same minimum but a higher maximum so if you want it to go up higher but not go down lower you'll use multiply because if you get 0 it'll stay 0 so they'll be no or less but if you get 10 then it might go up to 100 so you've got really high and so on if you want to actually remap it there's okay smarter to dream up where you've T you pass in a certain value and that value is going to be between zero and one so you know in and out is actually between zero and one says the noise texture and we're gonna pass out our value between zero and and then whatever want so the higher this Y value is then the higher the actual and thing is gonna be let's make one more parameter we'll call it you know height okay and then height can be into a oops vector to and it can go into the y then that one now let's see if I've done this right cuz I'm pretty sure I have the reason why it looks like it stops there is because the height was zero so it's obviously not gonna go anywhere but if we change it in here so if we put height as two one two three four that basically increases the range of which they can be offset if you're looking from below it'll be a bit weird if you look from above it's correct it's just very spiky now but you know use this as you will it's more this was more of like a teaching lesson rather than actually like here's a cool shade you can use unless you do want something in your game where like it looks like this I don't know why you would you can apply this to other meshes and it will look weird I mean yeah that's to be expected it's like we can put 10 now so the range is like much higher the shadows go a bit weird when you've got you know it's spiking off that much but you know you cannot have it really low kind of it like really calm point one so at point one it's just kind of like no nicely moving up now you could even use point one for like a you could use this very water like shader if you wanted it to like move up and down a little bit and obviously you can tweak this to be like how how wavy the water is actually yeah that's probably the best use of this because obviously it's quite limited if you had like low poly water this would be a pretty cool way of doing it yeah I would recommend that if you're doing low-poly water you could have the with your shader you'd also mix in the albedo and the emission maybe to be the you know water itself but for the sake of the position you could have it offsetting like this and I think that'd be a pretty cool idea so yeah I don't for this much more I'll see this video obviously that's the point of this video you know use separate Versys and offset them with a noise and there you go I will try and keep making sure you graph videos whenever I get ideas that are possible show you a graph and if any of you find out about new features and shader graph before me then obviously feel free to say you know ask whatever you want join my discord join the other discord I'll put both in the description here's the here is the I need to change this height to one or something there yeah so you're here the nodes if you need to see them all linked up ignore that that's just putting the same shader on a sphere which we don't really want you can still carry on the shader you can adapt it to what you want you can change things don't think you have to follow me step by step unless you really want to I mean sure the last thing I wanna say is you know obviously comment ask for more watch my other videos if you want subscribe to see more and support me and helping you each 1000 because that's me my dream goal I mean thousands not a lot for some people but you know it would be nice to reach but yeah I hope you like the videos I've been getting lots of comments coming hard to keep up with them I've tried helping everyone that comments and you know some comments are just like nice comments anyway like compliments and you know it's always nice to receive those because it makes me happy that sounds weird but yeah yeah anyway thanks all for watching and goodbye
Info
Channel: Dapper Dino
Views: 30,207
Rating: undefined out of 5
Keywords: Shader, Unity, Shader Graph, Tutorial, Tesselation, Vertex, Vertices, New, Coding, Programming
Id: ze21n5-xPjk
Channel Id: undefined
Length: 16min 58sec (1018 seconds)
Published: Sun Jun 24 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.