Unity Shader Graph - Vertex Animation Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey what's going on guys today we are going to see how to make this cute little goldfish move around with shader graph that's right guys it may seem very simple but it isn't and I believe we haven't seen yet how to use vertex animation in this channel and this is a very good example and by the way these videos are mostly possible thanks my patrons and in case you're interested in supporting me you will get awesome rewards like visual effects packages from projectors to area of effects orbs shaders and many more effects for your games or for your projects I live to link in description go check it out it's really worth it so let's see how we can do this alright so if you want to follow along with this fish you can download here in bind swap and the links in the script it's a blender file but if you not have blended to export as an FBX you can directly import to blend file to unity so the next step is to create a new PBR graph name it fish animation which we need because we also want to use the normals emission metallic smoothness and Alpha clip properties to make our goldfish look great so once it's created you can open it in shader graph and first thing we need is to turn on double-sided it will just help to make some minor bugs a little bit less visible anyway the most important stuff in this shader is the vertex animation part and that's where we are going to start because if I come here to the shade that I already created you will see that I use all of these properties just to make to the goldfish look pretty and we will leave this to the end so the first thing we need to understand is that this shader will be lurking between the normal position of the fish and an animated position of the fish and for that we are exactly going to use the lerp node and we can get the position of the fish the normal position of the fish with the position note which we need to switch to object space and connect it to the input a of the lab note and by the way for those who don't know the lerp node will output the mix between a and B according to the T input meaning that if T is zero it will only output a which in this case is red and if it's one it will only output B which is blue and now the values between are a mix of a and B so that's it and in our case a is going to be the normal position of our fish and B is going to be the animated version and we are going to split these values so we can access the RGB channels which are basically the x y and z axis and we are going to literally only be changing the our channel the x axis which we are going to add something that will make the fish google something that will make the fish move over time basically that's really it the G and B channels are going to stay the same which means we can use a combined node or you can even use a vector tree node it will do the same thing and we can connect to G and B and not forget to are just like this now the result of this node we can connect it to the B input of the web node all right so these by itself on its own it's not going to do anything it's basically lurking between the two exact same positions so let's go ahead and make it move and the way we mostly make things move in shaders is with the time node and this time node will be multiplied by a vector one which we can add in the properties panel and call it the wobble speed for example with a default value of 0.5 or maybe even more now let's multiply both of this and our next step is to get access to the mesh position but in world space and it will allow us to control in which access it's going to move it's going to wobble for example in the first share that I made I like to use the shoes if they want to move up to happen horizontally or vertically alright so in our case let's for now multiply the G channel that represents the y axis with a vector one that we can also add in the properties panel and that is going to control the verbal frequency with a default value of 2 all right we can connect it to the multiply nodes and now with these we can go ahead and add movement with the verbal speed we are literally going to scroll along the y axis and now we all need to pass this information to the our channel the x axis of the local object position but we still need something to control the lerp note the T value and we can create a vector tree for now that is going to help us to see this in action all right we can save this and now back to unity we can actually go ahead and create the material will right click in our shader and now let me erase this and push the material to the respective folder all right now in go fish we can assign it to the first element of the material slot and we are only going to use one material for this now and down here if I start increasing the X to a tiny value like 0.0001 the fish gets a massive offset for such a low number and if I increase the Bobo frequency to a lot we can only start to see some movement happening and this is happening because we are in fact only offsetting the fish and not making a waddle and not adding movement it basically goes to a certain distance and it doesn't come back let's put it that way and when we make it Google is with a sine or cosine note these nodes and in the preview we can see this is Scroll in already which is good because the white values upset the fish while the black values who will leave it in the same position making the fish wobble and if we multiply this with a vector one we are basically controlling how much it will offset and we can call it the wobble distance with a default value of 0.5 and not 0.05 sorry and it can be even more by the way let's connected to the multiply and replace the connection to the ad all right let's save this and now the cool thing is that if we increase the x value of the vector tree we can start seeing these wobbling around in the y axis we can even increase the distance a little bit and now if we increase the frequency our poor goldfish seems like it's starting to suffer from a rare fish disease or something like that poor guy anyway it's still pretty cool the effect right and it's influencing only in the y axis as you can see and this can be controlled right here when we split the position note if we switch to the our channel we are basically making the sine wave go across the x axis as you can see and we could also switch it to the z axis if you connect to the B channel like this and we can literally see the sine wave in action but let's leave it in the X for now into our shadow and now it's only a matter of justing these values but that's basically it for the animation of the fish the wobbling of the fish let's just change this vector tree to a vector one and collect Bauval amount for example and we can delete the vector tree it's going to be a slider between 0 and 1 by the way and then let's simply connect it to the input of the lab and that's it we will see in a moment how this is working now if you want you can add albedo normal the emission the metallic the smoothness the alpha and the Alpha creep threshold properties and I'm not gonna go through them but you can pause the video and copy them basically the only thing you need to pay attention is that I'm splitting the main text and accessing the Alpha channel to connect it to the Alpha and with a vector one connected to the clip threshold which is basically a slider we will be basically able to control the transparency of the tails and the fins as well which I will show you in a moment so I'm just going to copy and paste this you can go ahead and pause the video and copy these nodes and connect them like this and after you have done so in unity we can assign the main texture if you are using this fish if you are using another fish it's up to you you know I'm just going to assign the main text to the normal strain the mission map the metallic map smoothness map and make some adjustments as well you can copy my values if you want and now down here we have the Alpha clip threshold and if we start increasing it you will see that it's starting to clip some parts of the tail and some parts of the theme of our goldfish and it's awesome now if you increase a little bit to bubble amount we get our fish moving around and if you guys want you can even put it inside a fishbowl like this and it looks great it's an awesome shader with several possibilities by the way yeah that's basically it guys and I want to say thank you to my patreon supporters and I want to say a special thank you to my super mega patrons which are Alex Diggs and Carl's guides Christian mercy my goblin plaque James Finley Jen's Anderson Johnny X through a minyan Mac martyr Ricky claim sham to a Booker T Rita X game dev and the Ione you guys are awesome and thank you for your very important support I hope you have all enjoyed this tutorial really hope to see you in the next one
Info
Channel: Gabriel Aguiar Prod.
Views: 45,870
Rating: undefined out of 5
Keywords: Unity tutorial, unity effects, unity special effects, game effects, unity particle tutorial, unity game effect, unity vfx, unity shader graph tutorial, unity shader graph, shader graph, shader graph tutorial, unity shader tutorial, unity shaders, unity fire shader, vertex shader, unity vertex shader, shader graph vertex displacement, unity vertex animation, vertex animation, unity vertex animation shader, shader graph water, shader graph animation, shader graph vertex
Id: VQxubpLxEqU
Channel Id: undefined
Length: 10min 53sec (653 seconds)
Published: Tue May 28 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.