Blender for Scientists - Getting Started in Geometry Nodes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this video is an extension of my getting started tutorial and deals specifically with geometry nodes or geonodes for short geonodes are incredibly useful and will largely be replacing blender's particle system which features prominently in many of my older tutorials for that reason i wanted to go over some basics here as a reference point so that in future tutorials we really can just dive right in as always there are timestamps below for those who want to skip ahead for now let's get started for this tutorial we're working with blender 3.0 or later as it has the new geometry node system today we're going to be making a modified version of this sort of effect with nanopillars that have molecules adsorbed to the surface the type of thing that you might encounter in surface catalysis this tutorial will provide a lot of detail but is still far from comprehensive geometry notes has tons of functionality hopefully it will give a good look into many aspects of geo nodes as well as some worthwhile tricks and considerations i've posted a shorter version of this tutorial specifically for those who just want the end result without the play-by-play explanation that is linked in the description in the future all of the tutorials will be in that shorter format but hopefully this provides some deeper insight to those interested to begin in blender 3.0 we're going to go to edit preferences add-ons and make sure that we have the nodewrangler add-on enabled geometry nodes makes use of a lot of shortcuts i'll actually be making a separate video dedicated to just showing some common shortcuts that i use and i'll link that in the description when it's up from here we will select our default cube come to the geometry nodes workspace and hit new the geonodes workspace is set up with a place to add your nodes a preview and the very important spreadsheet editor which gives information about the geometry itself for our cube you can already see the number of verts along with their positions in space information about edges faces corners and all kinds of other things that will become more relevant as we move along we'll return to it a bit later because it is useful for troubleshooting and understanding what's happening like any other workspace and blender you can make changes to the layout or you can simply add your own the geonodes window is also available in the list if you want to use it in a different workspace it's worth noticing that a geometry nodes group has been added to our modifier stack geonodes act like a modifier and you can add modifiers before or after them you can also add multiple node trees to a single object which can be very useful one thing worth mentioning right away is that if i add another modifier let's say a bevel then my geometry nodes network has disappeared if you want the nodes to stay in place then you simply have to pin them so select your geometry nodes and enable the small pin icon just remember that if you're using multiple geonose groups or geonodes on different objects that the pin will make it so that only the pinned selection of nodes is visible to simply reaccess all of the others unpin it and then they'll all appear by default geometry node starts by connecting an input group node to an output to alter the object you can perform operations between the input and the output if i were to hit shift a you can see that there's a full menu of options generally speaking most nodes are either for creating a mesh or a curve getting information about that object manipulating in some way or performing some kind of simple math we'll start by adding a mesh primitive object with shift a to replace the original geometry for instance i will add in a simple uv sphere and connect this instead of my input to the geometry output we now have a sphere however if i were to tab into edit mode you can see that my original cube is still in place it's my transformations in this network that is creating the sphere you can make geometry nodes out of both mesh objects and curves and both have separate controls node sockets and geometry nodes can be quite easily distinguished and are useful for navigating a network there are six colors and three main socket types the types are circle sockets diamond sockets and diamonds with a small hole in the middle you can think of circle sockets as applying to the whole mesh uniformly in contrast diamond sockets will act on the individual points in a given object the ability to interact with these individual points is part of what makes geometry nodes so useful diamonds with a hole indicate that they can accept input from either a circle socket or a diamond socket the main colors of sockets are light green or teal for information on geometry purple for vectors yellow for colors gray for floating point values a slightly darker green for integers and pink for selections or booleans you'll find nodes with both circle and diamond sockets for pretty well all of these colors a very simple rule is that light connects to like though this is more true for sockets than it is for colors you'll often encounter tutorials where people will connect color and vector sockets because both of these contain three values it's also common to connect a gray socket into a vector which will simply set all three values to the same thing if however you try to connect a diamond socket into a circular socket the connecting noodle will usually turn red which indicates that there's some sort of error and that geometry nodes cannot execute that returning to our basic node setup we're going to add in a mesh primitive cube and connect this to the output i want to use this version of the cube because it gives me direct access to the number of verts and the size of the cube the first thing i'd like to do is actually move this so that the object origin this little yellow dot is at the bottom of the cube rather than in the center for adding subsequent nodes in the tree geometry nodes has tons of options and so it's usually worthwhile to make use of the search functionality with f3 or to simply hit shift a and then use the search at the top in this case i know that i want to come to the geometry tab and add in a transform node which is going to allow me to move the cube that i've just added in future versions of blender you'll actually be able to pull out from a node and it will give you a number of quick options that you can select from once you've played around with geometry notes a little bit more you'll get familiar with where the nodes that you want to reach for frequently are you can also select a node right click and use add to quick favorites and then add it to your network by hitting q and accessing all of your quick favorites many of mine are for math options because i find myself reaching for them so frequently with my transform node i'm going to start by adding a 0.5 offset in the z direction because that is exactly one half of the z value you'll notice that the object origin this little yellow dot has stayed in place from here i'd like to be able to scale my cube in x y and z however if i try and use the scale settings in this node then you can see that it's moving both up and down and i'd like for it to actually only move up in other words what has happened here is that blender has tried to both transform and scale simultaneously what i would like to do is transform first and then scale to do that i'll simply select my transform node shift d drop it into the node network reset the z value to zero and now i can use these scale settings to achieve that effector that i wanted where z will only transform up and down i can also shift and left click to drag over any of these values to change them all at once which is quite useful for altering the aspect ratio with the x and y values this simple example gives a good general sense of how geometry nodes work the idea is that the group output node will first look backwards and then move forward what that means is that the output at the far end needs to figure out what to do it will keep going back along the nodes until it finds the first node in the network in this case our primitive mesh cube once it finds the first node it will evaluate from left to right first creating the cube then translating it up by 0.5 then scaling it in short this means that things are only evaluated when they need to be which makes blender run better i've been told that geometry nodes is pretty friendly as far as older hardware is concerned as a result let's return to our scene i know that i don't want to change the translation here this is going to largely stay fixed but i'd like to be able to control the scale without having to find the right node every time especially as the network gets much much bigger i could select my node hit f2 and then give it a label so that i would be able to identify it more readily but a better route is to expose the relevant parameters so they can be controlled from the modifier stack this is an incredible feature of geometry nodes and we'll see it throughout this tutorial the simple idea here is that if i want to package this up for someone else to use without looking at the nodes i can make certain parameters accessible to them i'd like to make the scale values accessible i could make all of them accessible by simply connecting the scale into the group input you can see that i now have access to all of them from the modifier tab if i only wanted the user to be able to make certain types of shapes then i could separate the values going into this vector with a vector combine x y z node this way i could separately hook up the x y and z values so they could be individually controlled or i could make it so that only the x and y could be connected or that the x and y would be connected to the same value in this case you would only be able to change these in one way and it would sort of resemble a square in terms of the perimeter we can also name any of the parameters that we're creating by pressing n to open the side menu coming to the group option and then naming the value appropriately in this case i'll call this substrate base from here we can also set sensible default values limits for the minimum and maximum values and we can write tooltips that if you were to hover over them here it would give you a description of what this does we'll continue modeling for now but it's worth remembering that exposed parameters should be given descriptive names sensible default values and possibly tooltips especially if you're going to hand off the node network to someone else we now have our base object from here i'd like to place something at regular intervals on the surface we also only want to place objects on the top surface and within the boundaries set by our base there are many ways to do this for instance i could use boolean math to select only the top surface verts that are not on the edges i'll cover that approach at the end because it gives valuable insight into some important nodes and logic it also helps understand how to make more complex selections such as checkerboards for now we're going to do something much simpler we'll start by hitting shift a and adding in a mesh primitive grid our goal here is very simply to place this grid on the top surface of our cube and have it always stay there to do that we're very simply going to move our grid up add in a geometry transform node and now i very simply need to access the z value from our substrate base to do that i can add in two nodes i'll start with a vector separate x y z and connect this into the vector and then i will use a vector combine x y z and i'll connect the z value in here i'll connect my grid into the transform and i will use my combine x y z and plug that straight into the translation right now you can't see any effect because this node is not connected to the geometry output i'd actually like to join both the cube and the grid so i'll select both the transform nodes at the end hit control number pad 0 to add a join geometry node and though you cannot see the grid in solid view if i hit z and come to wireframe you can now see that our grid is resting on the top surface to prove that our separate and combine xyz nodes are responsible for this translation i can select the combine xyz node and hit m to mute it you can use this at any point to troubleshoot aspects of a node network where m will simply hide the effect of a node if i hit and again the node will reappear in the network if for any reason control number pad 0 did not work do i join geometry for you it might be because node wrangler is not enabled but you can also add it as a geometry to a geometry node and just to demonstrate that this works if i offset my z value here you can see that the grid is always tracking the top surface i can also adjust the size of the grid and the number of points in this grid from here i'll expose the grid parameters for the x and y size and the number of vertices i'm going to do this separately so that each of them can be controlled and that you don't necessarily have to use a square aspect ratio in this tutorial i'm going to be placing rectangular nano pillars to act as catalytic sites i'd like to place them on each part of the grid and to do that i'll simply add in an instance on points node and connect it to the transform after the grid then i can use this instant socket to place whatever i'd like what i want is an adjustable rectangle and luckily i already have that from down here so i can select these nodes by holding down shift hit shift d to duplicate them and now i can connect the last transform into the instance socket you can see the rectangles are too big but i'll simply adjust the scale parameters down until they look reasonable and i can do that once again by exposing the scale down here you'll notice that if i were to have done this without relabeling everything i would have substrate base but it would just say scale and then i'd have another scale this is why it's important to label your node network so we'll call this pillar size and now i can adjust these values until they give more reasonable nanopillars take stock right now we have an adjustable base and the ability to put adjustable pillars on it i can change the size freely in both the x and y directions i can change the size of the grid i can change the number of points that i want to scatter on and i can also change the pillar size however you can see the nodes are already starting to look like a huge mess nodes tend to get busy quite quickly and it's best to group them and label them with their functions to do that i'm very simply going to start by dragging out all these top notes here because these are going to be related to placing my grid so i'll move them all together and i'll hit ctrl j to add in a frame i'll also label this frame by hitting f2 and calling this pillars if i really wanted to i could also come to the node socket and add a very specific color to this frame i could also add a second frame to the bottom set of nodes for the base instead what i could do is select all three hit control g and group that into a single node that has only the scale and the geometry as an output if i hit this little up arrow here you can see that i now have this node group which i could call adjustable pillars this can be quite useful if you're going to be reusing a set of nodes quite frequently or to just reduce clutter if i want to undo this at any time i can simply right click the node and choose ungroup for now i'm going to add this to a frame with ctrl j that i will call base substrate before we add any particles or nanotubes i want to talk briefly about instances and modifiers our base substrate is a mesh object our pillars are instances you can actually see this in the outliner 36 instances corresponding to the pillars and geometry data that corresponds to the mesh the pillars are effectively copies of this cube that we've created here this is important because they don't really show up in our scene statistics which you'll notice we have far too many points to have only 16 verts and 12 faces in this scene instances are really useful because they're very efficient for blender's operation memory use file size and render speed that said instances are not acted on by modifiers let's say i want to add a bevel modifier to everything in the scene if i come to the modifier stack and add a bevel modifier you'll notice only the base is actually being affected by that bevel the pillars are not being affected because they are instances if i want my pillars to be affected i have to use a realize instance node to turn them into actual geometry if i go ahead and do that on the output of instances on points i can choose realize instances and now the bevel is being applied to everything this is worth noting because even though we now have our bevel applied the way we wanted we've lost many of the benefits of using instances so we've created a lot more geometry in this scene in the future i expect we'll get a bevel node so that you could do this without having to realize the instances it's just something that's important to recognize because realizing instances also applies transformations to instance objects effectively doing the same thing as hitting ctrl a and applying the scale this can be an issue when we go to scatter objects later on and it can be useful but it also gets complicated quite quickly for now i'm going to delete the realize instance node by selecting it and hitting control x which will preserve the connection between here and here but delete the node in this specific tutorial we're creating a catalytic surface and we might want to have an atom adsorbed onto it specifically onto these catalytic nanopillars we'll do this by distributing points on the surface and then placing the molecule on those points up until now we've relied heavily on mesh primitives such as the grid inside our geometry node network however we can also use other objects or collections of objects from our scene inside the network to showcase this i've added a simple water molecule you can download this and many others for free from the cgfigures gumroad page to add our molecule i'll connect in a distribute points on faces node and i'm going to connect the instances socket into the mesh from here i'll add in another instance on points node i'll connect this into the join geometry to bring my molecule into the scene i'll simply grab the water molecule from the outliner left click and drag and place it in the node network i'm also going to select this box for as instance for all of the aforementioned benefits so this will effectively place the water molecule as an instance on the points we'll go ahead connect the geometry into the instance and right away you can see that our water molecules are huge we could adjust this by changing the scale here or by selecting our water molecule in the outliner tabbing into edit mode and then scaling it down as i mentioned before if i were to put a realize instance node between here and here that would make it so that the pillars actually have their scale applied because right now they're much taller than they are wide and long so we'll go ahead realize instances and you'll see this is going to create a more uniform distribution of points along these surfaces you'll notice right now that there's some overlap in all of the molecules and i could change this by lowering the density of points down until i have only a few if i really want to make sure that they're not going to overlap then i can change from random to poisson distribution and set a minimum distance between all the points i'll hold down shift and drag up until i can see that no atoms are intersecting with each other no matter how high i bring the density value something like this should work just fine plus on distribution is a little bit more computationally intense than random so where possible it's better to use random especially if you're going to be scattering a large number of objects for our water molecule we also want to consider the rotation and position to prevent it from intersecting with the surface of the pillars we'll start with the position all objects are scattered or placed according to their object origin to adjust the origin we're very simply going to select our water molecule zoom in on it and then from a top view i'll make sure i can tab into edit mode hit g y with everything selected and then just simply move this up until the little yellow dot is just at the base of the oxygen atom here every time this object is placed on the pillars it will now be placed from this point to align our objects on the surface i'm going to add a line euler to vector node and i'm going to connect the normal output of the distribute points on faces into the vector socket i'll then connect the rotation into the rotation socket on the instances on points and then choose the appropriate axes in this case y you can see all of these are now pointing in the direction that we would hope and they're all facing offset from the pillars if i'd like to add a little bit of extra visual interest i can add another node namely a rotate instances after my instance on points and then i can use a random value utilities node utilities random value set this to vector and connect this value into the rotation and change the axis so that it will only rotate in a way that i would like so let's say i want all of them to have a little bit of random rotation we'll try in this direction namely in the y perfect and i'll do this for 360 degrees or pi one thing that's worth noting is that even though the rotation socket is by default in degrees as soon as i start adding vectors that are using values in radians it will update to work with radians so this is a value in radians not in degrees altogether this works as a very general approach for scattering most objects on surfaces but it will get more complex for objects that are asymmetric or for collections of objects we also have two very worthwhile toggles on our distribute points on faces node and in our random rotation node called seed if i change between different seeds it will automatically change the random value that is being applied while preserving all of the other rules that we've created i briefly like to show another way of doing this by instancing a primitive uv sphere so instead we're going to add another distribute points on faces node connect this to our pillar's output add another instances on points connect this in and we'll instance a simple mesh primitive uv sphere and connect this to the instance option i'll bring the scale down until it's a little bit more sensible and you'll notice that these are effectively embedded in the surface i could go ahead and try and offset the geometry again and do all the same rotation alignment that we did for the water molecule instead we're going to go with a slightly simpler approach we'll add in a scale instances node and connect it to the output of our pillars now we can use the x and y values to drag this out you'll notice that this is distorting the spheres and to correct that i can again use a realize instances node connected right here that will reset the scale and so now from an orthographic side view i can simply adjust the scale values until in both the x and y direction the spheres are offset from the surface and i can add a translate instances node and drag up in the z direction until i have everything offset there as well once again we still have toggles for density for random for poisson distribution and i could set everything up here to be however i liked as well and use different seed values to oscillate through a variety of selections the key point here being that there are a number of different controls that we could work with if we wanted to for our final version i'm going to expose the water molecules instead of the actual spheres that we've created here so i'll group these again call these spheres disconnect this and instead connect back up our water molecules realistically i'd like to be able to control several of these parameters including the size of the molecule the rotation the offset all of those from the modifier network in geometry nodes and so i'll expose those and then give them more sensible names and we'll come back to it now that i've cleaned up the nodes and added sensible parameter names let's go over some of the aspects of that quickly you'll notice that i added another group input node in addition to the one at the beginning you can simply do this by coming to group group input and though many people like to connect all the nodes into one group input i find that a little bit messy because it puts these noodles all the way across the screen instead you can simply add the group input where you need and connect all the relevant parameters in terms of connecting the parameters for our molecules you can see that i've added molecule spacing density random molecule selections random molecule of rotations and also molecule size i use the combine xyz trick to make sure that all of these go into a single value so no matter what i change here the molecules will scale uniformly i've also made it so that you could select the actual molecule from the modifier stack so if i want to change the water out for something else i could easily do that at this point all that would be left would be finishing touches namely materials and shading if you're familiar with blender you'll notice that selecting your object and right clicking shade smooth doesn't seem to be doing anything likewise if i were to come to the material tab and add in a material and change it that's having no effect as well that's because we need to do these things explicitly in our node tree for shade smooth it's often convenient to either shade everything smooth at the end or only at the parts you'd like i only want to make the base shaded smooth because it is the only part that the bevel modifier is being applied to and so to do that i'm going to find where my base object would be right here i'll add in a mesh set shade smooth and connect it right here you can see that has now been changed i don't have to do that for my atoms because they are already shade smooth and they will inherit both the materials and properties of the original object unless i choose to override them in the node network which i could do if i wanted to add materials it's a similar idea so i'm going to come to materials set material and i'll place one set material node on the pillars shifty duplicate this and add another and set that for the substrate then i can come to a material stack for the specific object and add in whatever materials i want so i'll call this top one substrate i'll call this second one pillars and for the substrate i'm going to go with something glass like so fully transmission lower roughness value and for the pillars and we'll reset it so it's not green and for the pillars i'm going to choose a very simple shiny metal you'll notice that nothing has happened yet it's because i still haven't applied these and in fact i'm going to expose the material parameters into the group input so we'll connect this down here and we'll connect this down here and again we'll relabel these more sensibly so this is pillar material and this is substrate material and to move those to where they should be in the node stack i'll simply select it and click the up arrow until all of my pillar toggles are together and i'll also move the substrate until all of those toggles are together and now i can select the material that i want so substrate and pillars if i hit z and come into a rendered view let's use the cycles render engine you can see that i now have my glass substrate with my metal pillars we'll use scene lighting for this and my oxygen atoms or my water atoms sorry placed on those pillars appropriately briefly returning to the main layout window just to showcase this better the great thing about all of this is that i can hand this file off to pretty much anyone and through all of these controls they can customize this however they want they want a wider substrate that's a little bit shorter they want a bigger grid they would like to have the nanopillars be a little bit taller and maybe with a higher density of molecules i'll have to change the minimum spacing for that they'd like a different selection of molecules they want to put something else on they want to change the materials of the substrate all of these are controls that we've added that someone can work with without having to work with the underlying nodes and of course because we've made all these parameters readily accessible we could animate with them so if i quickly come back into solid view drag the molecule size back down to zero and insert a keyframe jump ahead by 24 and then bring this value up to say let's go with one now i can actually animate the molecules appearing on that surface the last subject that i want to cover relates to boolean logic and the spreadsheet this is just a bit more advanced but grasping this aspect of geonodes will really help unlock its full potential up until now we've been using geometry nodes in a very similar way to the older particle systems and we've been largely ignoring all of the pink selection sockets in my opinion these are where geometry nodes really shine because they let us easily create rules for working with our mesh we already sort of saw that with aligning the atoms on the pillars but say i want to scatter an object on every other point in the grid or only on points above a certain line perhaps i'd like to translate verts that are only facing in a certain direction this is one of the ways that geonodes really separates itself from particle systems by making these rules much easier to implement right here i have a selection of nodes that are replacing my solution of adding a grid and offsetting it instead i only have one single cube that is driving this whole thing right here this entire selection of nodes is essentially looking at all of the points on the cube and saying find me the points that are only on the top surface and only scatter only instance on points for those specific ones also only collect the ones that are inside the edge in other words they are not along the perimeter and that is essentially being achieved by grabbing the position of every single vert looking at the minimum and maximum value of every vert through attribute statistics then separating out all of the vector values and comparing x y and z to say where is it less than or greater than this value where is it both less than and greater than this value and by combining all these together i can create a master selection that will control exactly what i'd like to do covering all of these nodes is a little bit beyond the scope of this video but i wanted to highlight that this is something that can be done the major takeaway here is that this degree of control is possible for transformations for adding objects for setting materials and for many other things i'll be using this extensively in future tutorials and i'll work through it as needed at that time for a much better insight into how this works given in a far more accessible way i've linked erindale's geometry nodes 101 tutorial in the description they cover everything much better than i could and really make it accessible if this is something that you want to get more involved with on that note future tutorials will be much shorter and more direct and i'll be aiming to release all the nodes generated for free when possible with appropriate labeling and separate walkthroughs some of those tutorials will cover making regular and adjustable surface cutouts wire mesh networks vesicles micelles membranes scattered spheres porous networks and various polymers i'll also be covering some helpful tips for getting started and organizing your nodes in general if you'd like to see more examples of geometry nodes or find more in-depth tutorials the following is a list of channels that i highly recommend i find aarondale's tutorials especially useful and they cover the basics in great detail johnny matthews is similarly excellent and he's developed several nodes that will be included in future versions of blender for more of a science focus especially getting into the realm of animation i have to shout out brady johnson who is possibly the overlord of bioscienceblender on twitter he is making a series about adjustable dna histones and all and his tutorials are always excellent other than that arendelle cg matter default cube johnny matthews bbn 19 red jam 9 brady johnson blender guru bad normals and tegma bradley animation chris p c bailey film jimmy gunawan and especially for the spanish speaking community sanctus tutorials who is actually making me rethink that i need to spend more time practicing my own spanish because they are outstanding videos to wrap up with an essential summary geometry nodes are just a workflow and blender that chains together various nodes to create specific models or effects they are largely procedural meaning that you can easily customize and modify the final model they rely heavily on instancing of geometry which is more efficient for blender to work with and can lead to smaller file sizes faster rendering and smoother overall performance they're well suited to when you might have to make changes to a complex model or scene down the road for most cases where you want to scatter an object on a surface randomly or with regular order for models that have repeating features and when you're handing off a project to someone else who will have to change it especially if they aren't as familiar with blender or 3d in general geonodes relies on having blender version 3.0 or onward older versions such as 2.93 may contain the prototype geometry node system but it is very different and you likely won't find any tutorials for it going forward newer versions of geometry nodes use a fields system it is usually a safe bet that the tutorial mentions fields or has been released since december 2021 then it's using the most up-to-date version geonodes are a little different than conventional modeling they do have a lot in common with procedural materials and if you're interested i have a separate video on that linked in the description lastly geonodes are much more like programming in the sense that your nodes are providing the instructions for making the product instead of you making it yourself you will see many people indicate that knowing how to program will help you with geometry notes that is true but you don't need to know how to program it's more that the workflow is similar and will help in specific cases above all else and something i hope i've demonstrated today is just to remember that there are usually tons of different ways to achieve any singular effect i am a strong advocate for getting started with whatever gets the job done geonose is still growing and the tools and workflows will change as things move along the other main way to use juncture nodes is to make use of nodes that other people have created geonodes allows anyone to set up networks of nodes that can be handed off to other people and used without having to understand the underlying nodes this really makes them valuable to anyone starting out or to someone who just wants to make a figure without having to learn all the fundamentals of blender or geometry nodes specifically and with that thanks for coming out many thanks to my supporters on patreon who have been getting updates on this tutorial for ages it was originally supposed to be a much larger video i was going to cover all the future examples at once but that proved to be a little bit silly and would probably be several hours in length if you would like to support the creation of more tutorials or assets geonotes and otherwise really consider checking out my patreon every little bit really does help me not just run the channel but it also allows cg figures to support the blender development fund otherwise if you found this useful engaging or enjoyable consider subscribing sharing with your friends and colleagues and until next time you have yourselves a great old day
Info
Channel: CG Figures
Views: 19,185
Rating: undefined out of 5
Keywords:
Id: 2MhFG2t7cFM
Channel Id: undefined
Length: 35min 51sec (2151 seconds)
Published: Mon Jan 24 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.