How to Truncate Vertices in Geometry Nodes | Blender Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi yes hello everyone I'm gavin.js and today I thought we'd continue working with the platonic solids by jumping into truncation specifically vertex truncation what this means is we're going to chop off each vertex at a given distance and if we just scroll through our solids here we can see an example of what we're going to end up with so let's jump into this node and take a look at what we're going to be doing today so this entire workflow pivots around the mesh Boolean node what we're going to do is essentially copy some geometry to each point of our solid so that then we can use that in the mesh Boolean node to just chop it off at face value it sounds fairly straightforward but there's a lot of work we need to do to make this Dynamic so that we don't have to tweak our values for each different solid so with all of that said let's get into it okay so we've switched back to a cube just to have a little easier visualization here and I've got our mesh Boolean node this is going to do a lot of the heavy lifting and the first most intuitive thing to do would be to instance a bunch of Cubes To Each of our points so let's go ahead and do that real quick and yeah if we do that just right out of the box nothing's going to work quite right I mean we get some interesting geometry but this is definitely not what we're going for and if we use this neat visualization node that I made real quick and toss our wireframe in there which by the way this is just a delete node and a join geometry uh Delete set to only faces so that we only have the wireframe of one of our geometries but taking a look at what's happening we can tell that all of our geometry just got instanced as is and what we really want is to have each of our cubes rotated to align with the normal of each point that we're instancing them to so in order to do that what we can do is drop in and align Euler to Vector node and then if we take our normal node we can feed that into our vector and then our rotation into rotation and there we go we can see that each of our cubes is aligned to the normal of each of our points it's truncating everything really nicely this is exactly what we're going for so when in order to make sure it's really working how we expect to be let's just scroll through all the other solids and yeah with the tetrahedron here it's working fine our cube is looking great our octahedron looks really neat but our dodecahedron looks kind of weird and let's turn off our wireframes for a moment and yeah this is supposed to be a dodecahedron and if we take a look at the icosahedron something weird is happening right the problem is that we have no control of how much each of these are being truncated and the amount that we want for each solid is different so okay how do we go about tackling that so let's take a look at our tetrahedron because this is the easiest one to visualize it has the least number of points and it's really important to know that our cubes are being instanced exactly at our points the center of our cubes is exactly at our point so now we know that that Z value the distance along the normal of each of our points is what's driving how much each of these points are being truncated so one thing we can do is drop in a transform geometry node place that here between our Cube and our instance points so if we take our x value and increase it to 0.5 we'll see that each of our cubes now sits exactly on top of each point of our tetrahedron and there's no clipping going on but now we need a value that we can vary to get from the full platonic solid to our maximum truncation which as it turns out is the Dual of our platonic solids so if we drop in a dual mesh and take a look at that we can see that for the tetrahedron it is exactly the same as the tetrahedron just smaller and inverted the cube becomes an octahedron octahedron becomes a cube and the same thing applies to the dodecahedron and icosahedrons they are inverses of each other so let's grab my nice little Boolean visualization node and if we compare the original geometry to the Dual mesh we can see that the distance between the point of the original geometry and the center of the newly created face is exactly the maximum amount that we would want to truncate so now all we need to do is find that distance since we know that the Dual of the mesh is just the center of each face turned into a point we can take the Dual of the Dual mesh and now we have points that we can measure the distance between so in order to get that distance we just need a vector math node switch this from add to distance and now we need the position of one of these points it doesn't really matter which of these points since they all have the same radius so we're going to throw in a sample index node plug in our geometry and change this from float to Vector then if we just plug our position node into value leave index at zero since again we're only going to sample one index then we can take that value and drop it into our distance node and leave this at zero zero zero because again we want the radius of any given point here and since this has gotten a little out of hand let me clean it up real quick so the next thing we want to do is drop in a value node this will be the parameter that we use to adjust our truncation and we need a map range node so let's take our value plug it into value and then we're going to switch our minimum and maximum values that way we're going from one to zero it'll make sense here in a second because if we look at our icosahedron here we're going to start at this point and then reduce our value but so that it makes sense when we're actually using this node we're making we want to take this value and increase it from zero up to one you'll see what I mean here in a hot second so now we can take the distance that we've calculated and plug that in to our minimum value and if we add in a combined x y z node we can plug that into our x value and we had this set to 0.5 for demonstration purposes earlier but we actually want to negate that so that it is set to negative 0.5 and the duplicate our transform geometry the reason for this is that since we're aligning along the x-axis we want to adjust our x-axis negatively here so that when it gets instanced it'll be moved up on the x-axis relative to the point so that our value of 0 means there will be no truncation so now we can take our combined XYZ and plug it into the translation of our second transform geometry node we can see that everything's lining up just as it was a moment ago each of our cubes are just barely touching each of our points and if we take a look at our value node and increase it we can see finally our geometry is being truncated and we can increase this value all the way up to one and at one we have exactly the Dual mesh of our original geometry and then of course going back all the way down to zero we have exactly our original geometry so now we can freely adjust our truncation our parameter will stay nicely within the values that we want to get exactly the geometry that we want and this will work with all of our different platonic solids so if we adjust our value to 0.5 and slide through our solids here we can see that the icosahedron gives us this classic looking soccer shape the dodecahedron gives us a very similar but not quite the same shape and in fact if we adjust this to 0.6 we get exactly the same shape then going down to the octahedron we get this really neat shape the cube gives us this fun shape and then the tetrahedron gives us the shape all of this is working completely perfectly we can even adjust everything all the way through zero to one for each of our platonic solids and we know that it is working perfectly for all of them except we'll occasionally get this weird error and I've run into a few different errors where at our extreme ends some of the shapes may disappear or get some really weird truncations so while it may appear as though we are done there's actually one more thing we need to do and that's just kind of correct for any weird errors that we might get so let me clean this up real quick and then we'll move on to the last bit here [Music] okay so now that everything's all cleaned up what we need to do is add in a couple of additional checks for our value here because if we drop this all the way down to zero at least specifically for the cube we no longer have any geometry which isn't great and I've had a couple issues come up when we have it set all the way up to one as well at the moment that's not really happening with any of our geometry which is great honestly but because I've seen these issues come up a couple of times while I was developing this and testing everything I think it's just better to add in both a check for if our value is at zero and if it is at one so what we need to do is drop in a compare node and we need to change this from greater than to equal then we can take our value here and drop it into a add a couple of reroute notes just to keep things a little bit cleaner and then let's duplicate our compare node and change our B value to one so now we have one that's going to look for if our value is set to zero and one that's going to look for if it's set to one now what we can do is add in a switch node and plug our first result in create another reroute node here off of our original geometry and let's plug that into true on our switch node then we can take the Boolean geometry and plug that into false so now if we take a look at our output and decrease our value back down to zero we can see we get our original geometry back which is fantastic now we're going to apply the same logic for when it's equal to one but since I mentioned that our fully truncated geometry is essentially just a dual mesh we're going to do exactly that and drop in a dual mesh node so now we can duplicate our switch node plug this Boolean operator into there plug our dual mesh into the second input which is the true input and then plug the results from our first switch into the second switch into the first input let's expand these just to show a little bit more of what's going on so for our first switch we'll take our original geometry into true and our Boolean into false for our second switch we will take our dual mesh into true and the output of our first switch into false and then if we wire that to the output everything should work just fine we aren't currently seeing any issues for when our value is set to one so I can't really demonstrate that this switch is working other than just stepping through and making sure yeah nothing weird happens there and of course if we go outside the range with our value then things get weird but we'll fix that in a moment there's just one more thing and that's to add a merge by distance node we'll just drop this and after our Boolean and that will clean up any additional vertices we have just in case anything gets weird so let me just clean this little bit up and then we'll wrap this up by turning it into a nice little note [Music] foreign okay and that's everything cleaned up now let's just grab everything we've created here hit Ctrl G to group it and this will make it so that a we have a nice you know singular node here and B we now have some parameters that we're able to play with so if we jump back into here we can select the group inputs and rename some of our inputs I'm just going to name our value truncation and then the most important thing here is that we change our minimum from negative Infinity to zero and our maximum to one so now when we jump out of this node we have this value here and if we delete our initial value node bring everything in so it's a little easier to see we now have this value that we can adjust up and down and we can't go beyond one and we can't drop below zero and if you hold shift you could more smoothly interpolate between those values and there we go that is vertex truncation done so if you've made it this far thank you so much for watching I really appreciate it it helps the channel out a lot and what would also help the channel is if you liked and subscribed that would be really awesome and I'd greatly appreciate it and if you have any technical questions I recently started a Discord server specifically for that because I think you're asking for technical help in YouTube comments is maybe not the best way for you to learn and for me to assist there's not a lot going on right now but I hope that that changes soon because I'd love to build a community focused around technical art and helping each other out so if that sounds interesting to you the link is in the description and I will see you in the next one bye
Info
Channel: GavinDotJS
Views: 1,413
Rating: undefined out of 5
Keywords:
Id: pSDNci6KwCg
Channel Id: undefined
Length: 14min 23sec (863 seconds)
Published: Tue Aug 22 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.