The Almighty Vertex: With Shadergraph (Amplify also available)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
Hello and welcome back to PolyToots, in today’s  video we’re going to be looking at how very simple   shaders, that all share the same basic principles,  can be used to make a lot of amazing things. Like if you wanted the sail of  a boat to bellow in the wind. Or you wanted to paint colours on an object,   without using any textures  and not worrying about UV’s Or add snow, moss or other  extrusions to an object. Or maybe you just want some basic animation, or  the ability to reduce objects to a singularity. I’m talking about the almighty vertex, and  we’ll be covering all of these examples.   As usual the final shadergraphs and amplify  versions, plus all examples you see here are   freely available over on my patreon, and  with that said I really appreciate any   of you who do support me over there. Also  worth mentioning we’re using URP for this,   should probably be the same  setup in other pipelines though. So let’s crack on with the first shader, the sail. I’ll also just create a material from  this shader by right clicking it,   and I’ll chuck this on our sails. The fundamental part of manipulating   vert positions in shadergraph  comes from the position node,  With this set to “object”, we  can multiply it by a value,   plug it into the vertex position slot and begin to  affect an object's scale based on its own pivot. Now that’s all fine and dandy, but we’re going  to need a bit more control than just scaling   our object, and that’s where the Normal Vector  comes into play. Again we’re going to set this   to object, and add it into our position  node. The multiplier here will act as our   filter, for whatever we want to hook into  it. For example if I just set this to a   regular float value like before, you can  see that we’re not just scaling the object,   we’re instead pushing the normals of the verts  outward. If you compare this to when we just   changed the position node, you should  get a better idea as to what’s going on. With this new information, we can begin  to create something a bit more suitable   for the effect we’re going for. I won’t  be going over everything in great detail,   but remember that all the final files  are freely available over on my patreon. So let’s get this up and running, we  need to push the sail outwards, which   we’re already doing to be fair, but we must try  to constrain the corners so the whole thing stops   blowing off. We can do this with a spherical mask  that’s pretty simple to create if you start by   splitting the red channel of a polar coordinates  node and flipping it inside out. The main reason   this will work is because I know the UV’s of my  sail are pretty much filling up my UV space, so   if I were to mask out the corners of a square,  it would also mask out the corners of my sail. After tweaking the masks scale, we can see  some good progress. Certainly not realistic   but real life these days is an absolute mess  so let’s all just stay in imagination land eh? From this point we can easily add in some extra  finesse, like getting rid of that peaky spot by   using a Power node to soften the result, we can  also create some hacky normals from this by using   the normal from height node so the shading is  a bit more accurate as we increase the wind. And of course we can throw in some noise and  jitteriness so that as the wind power gets   stronger it also flaps about like a.. A bird?  I mean birds do flap, but they don’t do this. And that’s pretty much it for  the magic behind the sail,   on this example I also enable backface  rendering as my sails are a one sided mesh. Next up we’ll look at some simple vertex  painting, in this example we’re just going   to be creating a basic shader that’s compatible  with vertex painting tools, but you can absolutely   extrapolate this information out to include  textures and not just colors, I have two older   tutorials on the channel that cover this,  they should hopefully still be relevant. The first thing we’re going to want to do is  install Polybrush from the package manager window,   this is included with Unity so you don’t  need to download anything from outside,   just go to the Unity Registry, find Polybrush  and install it. As an aside, if you’ve somehow   reached this point without having Shadergraph  installed, this is also where you can do that. You should see Polybrush up in the Tools menu now,   and if I open that, click on the vertex  painting option and try to paint on our mesh,   you’ll see that it doesn’t like that, because  no material on this object is compatible. So let’s fix that, make a shadergraph as usual,  make the material, slap it on whatever you want.   Then just look for the vertex colour node, plug  it into your Base Colour slot annnd you’re done. [Crickets] Okay so we can probably make  this a bit more interesting,   at the moment it’s still very cool and I  hope your minds are sufficiently blown,   but there is one extra channel we’re not  using at the moment, and that’s the alpha.   You can hook this into whatever you want, within  reason. Smoothness, Metallic, the actual Alpha,   even Ambient Occlusion. In fact you could  even go back to your 3d software, and bake   the AO to your vertex colours alpha, and use  that instead of having to paint it. Neat. So onto the next one, getting some snow or  moss or whatever to pile up on our objects.   This effect definitely works best if you  have more geometry to work with. That said,   the mesh I’m using has enough to do what we want. And if you’re thinking “oh boy, that’s a  nice bench, I wish I could get my hands on   something like that” then you my friend  are in luck, because this comes from a   new website called TheBaseMesh.com,  which offers completely free assets,   that you can do what you want with it. This  isn’t sponsored content or anything, it’s just   a new thing and I really like it. The meshes  are also super clean and come with basic UVs. So yeah go check it out, they also have a Discord  and accept requests, within reason probably. Anyway, the bench, right. So we’ve seen how  to push our meshes out based on their normals,   and that’s exactly what we need to  do here, but to also mask it in a   way that only parts of the mesh are  affected, and in only one direction. We can do that with a setup like this. We’re  just splitting out the Y normal vector,   which is the up direction in unity, multiplying  it for an initial value to start the build up,   and another value down here in the power  which will act as a ramp or falloff. So for the extrusion we can just feed this  into the same setup we had in our sail shader,   then we can take our Y mask, plug it in,  and hook it into the vertex position slot. And here’s a familiar issue, what’s happening  here is the mesh is being split based on our   normals. Meaning if we have any hard edges it’s  going to split the mesh. If you can’t or won’t   go back to your 3d software to fix this, we  can do it in Unity by selecting the object,   changing the normals type from Import to  Calculate, and just blast the smoothing angle up. As an aside, if you did want meshes with hard  normals and to also not have them split when   we do this, then you could use normal maps,  so the mesh itself will all have the same   smoothing angle, but your normal map texture  is what will give the illusion of hard edges.   I have another video that uses this technique if  you’re feeling like boosting my metrics today. So that’s the basics of this, and then it’s  just about adding nice little refinements,   like throwing in a minimum node with a small value   that we can use to make sure the  buildup stops at a certain point. We can also sort out the colours, having  one property for your base colour,   which could also be a texture, and  another colour property for the build up,   I’ve multiplied this by 5 from the  initial mask, because that way the   buildup colour appears much quicker, as opposed  to waiting until maxing out the extrusion. Lastly, If you don't want an even colour, like  for the moss example, we can multiply in some   simple noise here, and as a bonus we can use a  boolean with a branch to make this a checkbox on   the material. To be fair it also gives quite  a nice frosty look for the snow example too. Alright onto the next one, some basic  animation. The most common use cases   for things like this are fish swimming or  foliage swaying about. We’ve technically   already covered this with the sail example,  but this time we’ll use a different approach. To begin with, we need to make a mask  that will scroll across this fish,   we could use its own UV’s for  this like we did with the sail,   but instead we’ll make it so it  can make any fish or object swim. So for this setup we’ll start with the  position node and make sure it’s set to object,   then we’ll just split out the R channel and feed  it into a multiply with a float, this is going to   give us a gradient mask across our object. Next  up we feed this into a sine and this is probably   the most important node of this setup, in that it  allows us to have multiple waves of white lines.   So I’ll go ahead and turn this float into a  property so we can access it on the material. Now we just need to get it to move across  the fish, and with that we use a classic   recipe of time multiplied by a value,  again I’ll make sure this is a property. I’ll also tack on another multiply  and a float property to this,   we can use that to control the  overall strength of our wiggle. Shadergraph really likes position  nodes to be used at the end,   even if you’re already using them  somewhere else in your chain. So we’ll do that, set it to object like usual and  this time we’ll split this on the Red and Green,   this is because my fish's sideways vector is the  Z, which is the Blue channel, so I need to keep R   and G as they are. And for the blue channel, I’ll  add all this mask stuff we just made with the B of   the split, and then feed that into the B of the  combine. And that’s it, we’ll output the RGB 3,   stick it into the vertex position slot, play with  some of the material values and call it a day. Alright what’s left, okay singularities, cool. So we should all know by now that if  we were to just multiply our objects   position with a single value, we can  scale the object based on its pivot.   And if that’s all you need then more power  to you, you get to leave the class early. For all the cool kids out there though, let’s  get rid of all that and make something better.   I’m going to start in a similar way to the fish,  by creating a mask that will move up our objects.   We do that with this simple setup of splitting the  G of a Normal Vector, that’s the Y position, XYZ,   RGB, you get the gist. and one minus’ing it  before we add in our slider property. As you can   probably tell though, by doing this we’re already  starting with the mask half way up the objects and   I’m not a glass half full sort of guy, so we’re  going to need to remap this value so it starts a   little earlier. -2 should do it. Now we have  a mask will go all the way up from nothing. The reason I’m making this, is when  it comes time to collapse the mesh   I don’t want to do it all in one go, instead I’d  like to affect the mesh gradually, like with a   gradient. We can move onto the actual  collapsing now, just like society. We should saturate the result we have so far, and  then multiply in a position node set to object,   and then another multiply after that to control  its direction, technically it’s like a strength   but if you tell something to do minus a strong  thing then you’re gonna get a weak thing. Lastly, we need to add another  position node onto this at the   end before we hook it into the vertex offset. And there we go, if we set the direction to -1,   we now have the objects splitting and  collapsing down to their pivot points. From this point on it’s just a case  of adding whatever you want. In the   example that you’ll find on patreon  I’ve thrown in some noise which masks   out the objects with alpha and also  make the effect a bit more wobbly,   there is of course the glow and as one  final little treat, we can change the type   of collapsing to be based on a world position,  so you can set which point things collapse to. Full disclosure though, I was only able to get  this working on the Amplify version, I tried for   far too long to port over this one little detail  to shadergraph, but it just wasn’t having it.   I’m sure it must be possible, so if there’s anyone  out there who can crack that one, I’m all ears. So that, will be that. Thank you so much for  watching, don’t forget that both shadergraph   and amplify versions, plus all files including  some fantastic free meshes from thebasemesh.com   are available for download over on my  patreon, check the description for any   relevant links. Peace out, and  I will see you in the next one.
Info
Channel: PolyToots
Views: 18,942
Rating: undefined out of 5
Keywords: unity, sculpting, game dev, texturing, baking, unwrap, uv, game art, shaders, amplify shader editor, tutorial, shadergraph, graph, VFX, Blender, 3d, 2d, PolyToots
Id: 1N_4NzwprJI
Channel Id: undefined
Length: 12min 21sec (741 seconds)
Published: Wed Jul 06 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.