Transcript for:
Visualizing Index on Screen in Blender

a viewer recently asked how they could visualize an index on screen and another viewer hinted that you could use repeat zones but how exactly well let me show you so let's get set up for geometry notes we'll click the tab up top click plus new press a and scale these apart quite a bit first thing I want to do is delete the geometry uh but only the faces and that will let us see the wireframe a little bit easier so really quickly we can see text in the form of geometry using the string to Curves node and if we add a join geometry and bring this over and give it some text there is our text and let's fill this curve this string input here this blue dot is for text so we need to be able to make the text that we're inputting variable but you'll also notice it's a circle which means it's a single input unlike the field which is a diamond value where this represents multiple values being input or output but as was suggested we can overcome that with a repeat zone now the repeat zone is like in programming like a for Loop where you repeat a set of steps a certain number of times in blender terms one repeat of the loop is called a step and how many times those steps are repeated is called the iterations so if we want to display text at every point of this geometry text being the number we need to specify how many iterations that would be and we can get that value from the domain size node if we hook this up to the geometry input this point count will give us exactly how many points are up here that we see in the spreadsheet so we can use that as our iterations now within this repeat Zone we'll want this geometry to ultimately go to the group output and I'm going to alt drag this up here cuz I know I'm going to want to join some geometry together so within this repeat Zone if we create this text and join that geometry together let's bring back the original geometry as well in every step we'll be able to see this text at each position but what is the position well we know we're going to set the position of this instance to something but what is that something well how do we get the position of one of these vertices we can do that with a sample index node where if we take this geometry and we specify that we want a vector and bring in a position input now the output of this setup will give us the position of the element at index zero in this case it would be XYZ being 111 so if we specify that position and make sure we take this geometry output here and that has to come into the repeat Zone as well so you can see it's there this is position zero this is X1 y1 Z1 but let's use the offset instead so it doesn't squash the text together sweet so that's only one index though so now what we need to do is we need to specify the start yeah right here are your initial values coming into the repeat zone so the values come in they come out here into the repeat Zone flow through the repeat zone are plugged in here and then when it Loops back through the loop is like this so the initial values are here it's a onetime setup within the Zone itself they can be read or they can be updated uh to be used in The Next Step so to start I want to say let's start at index zero and this integer will be used throughout the step and we'll increment it before we end our step but I want to rename that first by clicking the repeat node zone or the repeat Zone node click node here and let's just name it I which is kind of a conventional for Loop counter in programming so now we have I starting at zero it's used in the repeat Zone let's make sure before we forget to increment that by one for every step so now instead of using this fixed index zero if we take I and plug that in you can see that we see text at every point in the geometry now the last thing to do is we need to make sure this is displaying the right value instead of the word text so we can delete text but if we try to take this I value and plug it into the string input blender complains they're a mismatched data type these inputs and outputs are incompatible so we can undo that and bring in a value to string node and pull that into the value input and now whatever value it is 0 1 2 3 Etc will just be converted into a string so string out to string in that'll give us our numbers as we expected and you can if you want you can uh rotate the instance rotate instances to give this a 90 on the X however you want to see these numbers for visualization purposes all right so that's how you can visualize the index number for each element in your geometry if you want to set this up so that it's a node group that can be reused simply later on let's select all of these hold on I see an issue here we start off with eight vertices but now we have 16 so we're doubling up the geometry all right it looks like it's these connections here we'll just dissolve these and dissolve that with crl x the reason was the original geometry was being joined with the output of this repeat Zone but the repeat Zone has the original geometry in addition to the extra text geometry as well so it doubled up the vertices of the original mesh all right problem solved we can now take the this area contrl G and that moves us into this node group you can see the path Cube geometry nodes geometry nodes node group so if we press tab to back out now all of that logic is bundled up into this custom nose Group which we can call visualize indices all right give that a fake user and to show how reusable it is we can add a grid add a geometry node setup for it and we can call that node group up with shift a visualize indices and whoa that text is really big so if you're serious about holding on to this setup for debugging visualizing later you might want to make a a group input here for the size of the text but there is the order of vertices in this geometry so super cool to visualize this let us know how you plan to use this in the future if you found this helpful give the video a like And subscribe would love to have you as a part of the Community take care