Fish Scales in Blender: How to Cover Any Object With Scales (Geometry Nodes)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi i'm chris bailey and i make blender tutorials over at youtube c bailey film and today i'm bringing you this tutorial with cg cookie we're going to be talking about how to put fish scales onto any surface using geometry notes let's get started now don't forget to head over to cg cooking.com we've got a ton of amazing blender training material and resources there for you along with some amazing blender artists ready to answer your questions head over and enroll today okay welcome we got a fresh scene here and what we're going to do is talk about how to use geometry nodes to procedurally put scales or fish scales across the surface now fish scales are really complex let's have a look at why okay so here's a picture of some fish scales and you can see what's going on is that we've got these these uh disc shapes like this that form the actual scales but then they're offset on each row so you get this alternating pattern where each set is offset just a little bit right so they kind of interlock and overlap in a specific repeating way okay so let's get started what we're going to do first is pull up our timeline we're going to switch this over to the geometry nodes editor and then i'm going to split my view here and i'm going to grab my spreadsheet just so i've got some uh clear view on the numbers and what's going on with the actual things that we're doing we'll talk more about this in a bit so i'm also going to get rid of my point light and my camera just to clean up the scene so i'm just looking at the cube now i actually don't use a cube i want to simplify this a little bit more so we can talk about the concepts first so we're going to use a plane so let's go ahead and delete that shift a mesh plane with this plane let's create a new geometry node so we'll click new here and we'll just type in scales okay so what we're going to do first is i'm going to switch to wireframe mode so i can actually see uh the mesh of this object because everything we're going to do is depending on the mesh of this object to get to work the first thing i want to do is create a little more mesh so a few more subdivisions so we've got a few more vertexes to work with i'm going to go right here shift a and i'm going to type in subdivide and i'm going to grab the subdivide mesh node i'll drop this here and i'll turn the levels up to two i think it'll be pretty good now let's talk about what we're gonna do and how we're gonna make this work the easiest way for us to do that is to instance our scales so make our scales appear wherever there's a vertex on our piece of mesh so we've just subdivided our mesh quite a few times and so now we've got quite a few vertexes that's each of these intersection points and right where each of these lines start that's another one you can see here we have 25 now listed so where each one of these things are that's we're going to put a scale so now how do we get that offset pattern how do we get this to look right what we're going to do first is let me um i'll actually instant some geometry here so we can see it and then i'll talk about how we're going to offset things to make it work so i'm going to go shift a and i'm going to grab a instance i'll type an instance and instance on points node i'll drop this here and then i need to have some kind of geometry instance so i'm going to go for mesh primitives and i will get a mesh circle because that's what we're going to be using to make our scales anyways and i will bring the radius down so they're not overlapping so much it's a little bit easier to see okay so we've got our scales and you know you can see there it's an even grid right so how do we take this even grid and change it so that we've got an offset row like how would we take this row for example and offset it or actually just to be even clearer let's have a look at it if we added a new row in of vertexes how can we subdivide this mesh so we could get scales all along here if you imagine each of these is a face right on my grid and i have four vertexes for each of these faces if i want to have one in the middle how could i subdivide this so that i get that one without getting any other vertex if i was to just subdivide it normally it's going to do this and that's going to give me a vertex in the middle which is what i want but it's also going to give me these extra ones on the side so i'll end up with circles here and here and here and here as well which i don't want so in order to just get one in the middle i actually need to cut it like this by creating an x pattern next cut right through this polygon i'm not going to get any extra vertexes i'm only going to get that vertex i want which is the one right in the middle and it's also going to be exactly halfway between both the points on the on the horizontal and the vertical so it's going to be right in the middle of those guys which means it's going to be a perfect row a perfect offset of the previous and consecutive rows so using this x cut is going to be really useful for us to achieve this pattern in geometry nodes we have a node to create this kind of a cut and it's called the triangular node so let's have a look at what it actually does i'm going to unplug my instance on points node and i'll just take the mesh right here and i'll just plug it into the output so we can look at our grid again just by itself now i'm going to grab a triangulate node triangulate node will triangulate mesh and you can see here it's taken each of our faces and it's turned them each into a triangle so it's cut it in half now it hasn't created the x pattern and it's using this shortest diagonal which is actually going to give slightly different results depending on the shape of your object so we have very equally sized polygons right now so we're getting the same result this is going to give you a different result if we have say for example a sphere you can have lots of weird cuts in different places so to get a consistent cut no matter what the shape or size we want to go with fixed so let's switch that to fixed now we can go one way the other fix alternate just swaps the direction and you might say to yourself okay great let's get an x by you know having two of these fixed fixed alternate bring the mesh and then let's join the geometry right drop this here and then bring this one here now suddenly we've got exactly what we're after this x pattern but it's a little deceptive because what geometry nodes has actually done here is it's made a cut right through the middle and then it's made another cut and then it's joined these two but it hasn't joined in a way that merges all these such that it creates a vertex here in the middle of each of these points vertex count is now 50. it's actually double what it was before it's because it's actually just taken two versions of this one that's cut this way and one that's cut this way and it's duplicated and it's put them exactly on top of each other what we want to do is we want to separate separate these new edges that we've just made we want to separate them out and then subdivide those so these individual edges now have a vertex in the middle so they become two edges in order to separate out the edges that we want we're going to use a node called the separate geometry node we'll drop this here we're going to switch it from point to edge because we want to separate and separate out edges and we need to feed a selection here now we're going to be working with the index number that's what these represent so we need to feed an index number in here to tell geometry knows which ones we want now you might be tempted to think you could just put a number in so if you wanted number 10 you know grab a value node type 10 into it plug this in and unfortunately it's not going to actually work so you can see if we move this around it's not doing anything but turning on and off it's because you can't actually put a number in you need to put in an index which is a specific type of attribute plus we need to kind of give it a range of attributes so the way to set this up is first we need to get the index so there's a node specifically for index now we need to say okay which index numbers we want so we need to do some math on this index and that's how we can then pass it on to this node so let's go over here we'll grab the math node and we'll drop it down and let's say let's go with the greater than function so i'll plug my index into the value now i get this threshold and i can plug this one into the selection you can see we've also got this dotted line that means now it's going to be looping through all the values so it's going to go through all the different indexes and all the different edges in our geometry and it will spit out a selection that will be everything that meets this condition so everything that has that's every index is higher than 0.5 so we don't have any indexes that are in this sort of half decimal range so we just need to drag this thing up and you can see it start to work right here we go so let's get rid of these annotations so they're not in our way so you can see if i drag this all the way up let's get to the point we've got the right edges okay there we go so now i've got the edges that i want right they're actually selected because here we've got 16 edges now we've gotten rid of a lot of what number is this well see it's 39. we go to 38 let's just check yeah so 38 is where is the first time we start getting one of the edges that we don't want so we just want everything over 39. so why 39 why is it a special number uh it's a bit confusing if you're looking at this many edges but if we just drop this down to one uh you'll start to see what's going on i can increase this up until everything disappears except for the edges i want and bam that we can see so round 11 11 is the secret number that gives me just the edges i want so why 11 why would that be the number well the reason for that is if we come over here plug this one in you can see that when we have our triangulated mesh we've got 16 edges but when it's just the subdivided mesh we have 12. remember with the index the first one is always zero so index number 11 is actually the last index for this piece of geometry when we triangulate it these new edges get added on after 11 so you can see here that 12 13 and 14 and 15 are these new edges so by separating the geometry where we grab everything that has an index higher than the number 11 it's gonna grab 12 13 14 and 15 which is exactly the ones that we want now that logic holds up no matter how many faces you've got right the number of edges in your piece of mesh is always going to have a certain index a certain number of indexes when you triangulate that mesh there's always going to be all the new edges are always going to happen after that first group of index so if you can get the number of edges you have on your mesh before you do the triangulation and then compare that to how many edges you have after you're able to get the indexes for just the slices that are diagonal i hope that makes sense once we've got those using this set up here then we can subdivide those so i can come over here and i can grab a subdivide node certified mesh drop it here just a level of 1 and that will now subdivide each of these guys so you can see now we actually have eight so if you just have a look if we go zero we've got four edges and then if i set this to one we now have eight nothing visually changes and so that means these guys have actually just been cut in half all right so how do we know what the threshold needs to be how do we get that number we're going to grab the attribute statistic node type in attribute statistic you can also find it under here under attribute it's one of the only three attribute nodes now this attribute sticks to node gives us all kinds of information about any piece of mesh i'm going to take my subject mesh and i will drop it into the geometry and i can switch this from keep this to float i'm going to switch this to edge and then i can grab the max value this is going to be the maximum number of edges as a floating point number in my mesh so if i was to take this right you would think great i can just plug this number into here you'd think it would work but of course it doesn't things start looking pretty crazy now it's a bit confusing what's happening because the subdivide mesh node so if i just mute that by hitting m just turning that node off you can kind of see what's happening now we're actually only selecting one edge so this isn't actually working this isn't giving us the number of edges and the reason for that is we're missing the attribute input what we need to put in here is uh what is it that we're looking for what does this floating point need to be right blender doesn't really know we're saying we want edges but we're not saying what we want about the edges like does it we want like the z position of every edge do we want the x position of every edge doesn't know what we want is the index of every edge so what's the number of edges what's the number of indexes that we've got um so i'm going to grab the index i just duplicate this one and i just plug this into that now it's going to work because it's taking the index of each edge and it's taking this mesh and then it's outputting the maximum values what's the maximum index the maximum index in this particular case is 11 and so when i say take the index take every index that's over the number 11 and separate it out after we do the triangulate we're taking those extra edges and we're separating them out now if i unmute this we're going to subdivide this we'll get the double bit and now we've got pretty much everything we need to create the scales in the way we want so let's have a look now you might be wondering why don't why do i have like the grids again like what happened to the polygons like don't we need those um and i don't actually need them anymore because you can see i've got enough vertexes you can see that we've actually got the same kind of grid pattern that we're looking for without having to bring in those other edges so let's take this and we're going to drop this one here and then we'll take our mesh circle again and we'll plug it into the instance and bam there you go okay so now that we've got the offset pattern that we wanted to this is the most complex part of our setup what we need now is to just basically make some scales out of this mesh circle so we do this pretty easily what we want to do is we can just have a look at this by itself uh probably a bit easier so i'll just plug this in i'll get rid of our annotations go back to shaded mode and come over here to our mesh circle i'm going to fill it with uh let's see triangles we find see what that looks like if we go into uh mesh mode that's what the triangle setup looks like and what i want to do is basically stretch this thing out and scale it around a little bit and we can create some some cool uh shape using geometry nodes to get this right we could also easily just model this object we don't have to do this part in geometry nodes so it's kind of up to you how you want to do it it's probably a little bit easier just to model it to be honest but you get a bit more functionality if we do it in geometry nodes we can actually control these values a bit more specifically just to make sure it works so first thing i want to do is move this section up right let's uh let's do that so i'm going to grab i'm going to grab a math node and i'm going to grab a separate x y z and i want to move the vertexes of this around so i need to select some vertexes so i'm going to use the set position node i'll drop this here and then i'm going to grab the position node and i'll plug this into the vector so what this is going to do is take the position of every vertex in this object that we're working on and i'm going to separate out where is it on the y so where is it along this y axis and i want to say i'm going to grab everything so i'll plug this into the value and i'll go less than this time so i want to say everything that's less than zero these are the ones i want to be my selection and i'm going to offset those along the y negative uh actually i won't go the other way don't do that once i'll do greater than and go positive so we'll stretch that out so we're just stretching out this shape next thing i want to do is take this group and i want to kind of lower it down in z space so that it kind of drops a little bit for me so i'm just going to do that here pretty simply all right so now that we've dropped this back end and uh extended it out a little bit these guys are going to kind of slot under each other okay so let's have a look at how this affects the overall style so plug this into the instance and plug this back into geometry now the first problem is we need a lot more than this so we can do this in two ways we go over here and increase the subdivision but because you want to be able to put this on different types of objects with lots of different you know maybe densities of mesh probably one size doesn't fit all so we want to have a control on this that's sort of custom per object so we can set it so i'm actually going to click the input here and drag it here to subdivision this will elevate this to our modifier stack itself so i can now come in here and change the number of subdivisions that i uh that i want so now we can kind of look at how well these guys are overlapping and what issues we might have so i feel like this is a good level of density but you can see that they're intersecting a bit too much decrease the radius a touch yeah there we go that's a bit better so you can see we've got this interlocking pattern where these scales are kind of traveling underneath each other now we are getting kind of a weird pattern with these scales we're giving this bizarre kind of like point here that's because of the triangulated faces on our mesh circle that we started with so what we could do is actually come over here to mesh primitives and grab an isosphere instead and we could match the radius and we could plug this in here instead now of course everything's going to be these you know large large spheres but we can shrink it down over here we grab a transform node and drop it right in here and then we can scale it on the zed to kind of flatten it out quite a bit you can see our other aspects that are going to work could also probably increase the subdivision some and that will give me more of something that works a little bit better i think now it also be good to shade this smooth so i'm going to come here and grab the set shade smooth node and drop it here and with that ticked it will shade all of these guys as smooth and there you have it we've got an actual scale pattern now let's see how this behaves on different types of objects i'll come over here grab a uv sphere bring this up and let's click new for new geometry nodes and then grab scales and you can see right away we've got a very cool result but we have a problem they're not actually rotating appropriately which means we need to do one more step to get this to work on anything and that is to set the alignment of these guys with the surface of our object now we're going to input this rotation fix into the rotation input of our instance on points because this will allow us to rotate each scale individually based on some information that we feed into it so we're going to use the align euler to vector node and drop this here this is always the node you're going to use to align a lot of instances to geometry so you get used to using it even if it's a bit confusing here at the start okay so if we take this line euler to vector and we plug it into the rotation you can see it doesn't work yet so it's just rotate everything but kind of uniformly it's not really doing something specific now usually what you would do is you would grab the normal node next grab the normal node because the normal is the direction that every face is pointing but you can see if i plug the normal in to the vector it's giving us some very bizarre results even if we swap these around it's still not quite working see they're really overlapping incorrectly so what's going on how can we fix this well what we want to do is actually the problem is it's taking the normal of our separated geometries it's just looking at this new version of the geometry where it's just edges and that's going to give us some very strange results what we want to do is actually step back a few steps and grab the normals either from our base mesh or this triangulated version of the mesh so how do you do that how do you grab this normal node doesn't have an input to say okay which normal do you want it's just the normal which can be kind of confusing but it's always taking the normal of whatever is that's feeding into the node that you're using it with so it's looking up the chain it's going okay we're getting this so this is the one that it's using for the normal so in order to get the one that's back here we need to grab an attribute again we need to transfer an attribute from here over to here so to do that we need to use the transfer attribute node so we're going to be transferring a vector because we want the normal a normal is a set of three numbers that describes the direction that a face is pointing in on the mesh so if we grab our triangulated mesh before we separate things out drag it here to the target now we're going to tell it what are we grabbing what actually are we grabbing we're grabbing the normal so i want to grab the normal of this thing here and i want to output a vector so i'm going to actually just output the uh the normal itself straight over you've got this option nearest face interpolated nearest or index and we could probably just leave that set to nearest face and i'll take the attribute and i'll plug this now into the vector because this attribute we know now is a normal from this object over here so i'll plug this in all right so still doesn't look quite right this is because the the size uh is a bit too big we come over here to our radius and we can shrink them down a touch see there as we adjusted the size of these guys they're starting to fit a whole lot better you can see how that rotation actually works pretty well now there's a few other issues we've got if i increase my subdivisions on this in the geometry nodes you can see we're starting to get a grid pattern and that's not looking good at all on our sphere whereas it looks fine on the flat plane and that's because this is actually a round object and by subdividing a round object it's not really giving us the look we want so if you're using it on something like this it's probably better not to have this as an option within the geometry nodes and in fact come over here and just use a subdivision surface on whatever object you want to have this on so that you know it's actually a rounded set of subdivisions now if i create a cube shift a cube bring this up i can place this in my scene just put it next to my sphere here and click new for geometry nodes and go ahead and apply scales to it right now i can use my levels to increase this this is another using a cube it's a good time to use a subdivision surface modifier as well so let me just throw on one of these simple just to kind of subdivide everything and firm up the edges a little bit and then i can do another subdivide subdivision surface sorry drop it here and keep this one set to camel clark and then if i set my geometry units level to one and pop this to two you can see it's starting to round the edges in a way that looks really nice and helps wrap those scales now i've created three different objects here we've got a taurus a sphere and a cube and you can see you can see through some of these like with the sphere and the cube whereas the taurus the scales line up really nicely so it's clear that you need some kind of value to manage the scale of your scales and scalar scales for each individual piece of mesh it's probably way to do this with math so that you could actually look at like how far away a vertex is from its nearest neighbor and then use that to be the driver to calculate the scale of the individual scale and you have like different size scales depending on you know how spread apart the mesh is but that's probably a bit beyond where we're at with this tutorial we just need to create an extra step here for working on our radius or our scale of our original isosphere instead of just working with such a small number i'm just going to grab a transform node and just drop it here and then what i can do is grab a combine xyz node and plug it into here and then i can just grab one of these outputs here from our group input and plug it into the x then i can also take that same one and plug it into each of these this will allow me to have one floating point number that i can use to change the scale of everything so instead of want a zero if we set this back to one everything will reappear and we'll lose the other ones because we've just created an external variable and it defaulted to zero so i just need to set it to one here with these guys grab the cube now i can come into this tourist for example and use this value to fine tune the scale so i can just hold down shift and drag until everything is overlapping nicely come over here instead of saying gaps through i can grab this one now and just expand the scale up for these guys great now the last step you want to do is set some kind of material on these guys um and that's pretty easy to do right here at the end we just go set material and uh we can actually put this on each of the scales individually if we come all the way back to the isosphere we can set the material here and just create a material for our scene called the scales and then we can select it in the drop down and now if i switch to rendered view i'll just turn off scene world so we can see see some light we're going to get a nice nice view of our scales and we've got a material now that we can work with in our shader editor now just to do a simple example of how you might create some interesting looks on these scales we can create a gradient so shift a type in a gradient texture and i'm going to grab a color ramp let's take this gradient texture we'll plug the color into the factor and plug the color into the base color and you can see there that it's creating a nice gradient from one side to the other but if i want to rotate that just grab a texture coordinate node and a mapping node plug the generated into the vector and the vector into the vector and then i can just rotate the whole thing i rotate the whole thing on the z 90 degrees and then i go to the x location and just drag it back so i can drag it up there we go now i'm getting this nice gradient where the base of my scale is dark and the tip is quite light now i can set some nice colors i'm looking for like a fish scale going to look like a darker blue and then like maybe a light brighter blue and then i might take my roughness down so they're nice and shiny bring my specular up and there you have it we've got a procedural system using geometry nodes that can put fish scales onto most any mesh pretty cool hope you really enjoyed this learn some really neat tricks about how to transfer attributes move position values around some complex stuff so feel free to watch this one again take notes and try to really wrap your head around these concepts and you will start to fly using geometry notes trust me don't forget to hit that like button and subscribe to the channel if you want to find out we drop new tutorials and please leave us a comment let us know what you thought of this one and what you'd like to see in the future we'd really appreciate it don't forget to check out cdcookie.com i'm chris bailey it's been great to be with you today i hope you enjoyed this tutorial i'll catch you in the next one until then see you later [Music] you
Info
Channel: CG Cookie
Views: 63,759
Rating: undefined out of 5
Keywords: Blender tutorial, learn blender, CG Cookie, blender beginner, procedural, geometry nodes, fish scales blender, blender scales, blender how to
Id: fmDv81dMQ6c
Channel Id: undefined
Length: 26min 13sec (1573 seconds)
Published: Tue Apr 19 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.