1
$\begingroup$

I have a bit uncommon question . Let's say I have a simple plane (with 4 vertices) . I have added a XYZ Attribute separate node, which takes the "position" vector as input and splits it to float attributes : "x" "y" and "z" .

As I can see on the spreadsheet each vertex has its own values for x,y and z. The way I understand GeoNodes concerning attribute math is that it works "per vertex" kind of.

Let's say if I add a function (through attribute math) of the kind f(x,y) = sin(x-y) and apply it to the z-value , I see different results. My question is how can I access other vertex' row data ( we have for rows - 0 to 3. Can I access row 1's y-value while being in the loop of the calculations for the 1st (0-) row ).

Or in other words - If we represent the vertices as grid points V(x,y), how can I access V(x-1,y) or V(x,y+1)?

$\endgroup$
3
  • 1
    $\begingroup$ As far as I know you're not supposed to think of this in terms or rows and columns, tables just are a visual aids for inspecting data not a "excel" to manipulate it. You are still supposed to access and modify data through the nodegraph. If a vertex is in the next line then it means it is probably the next one in terms of mesh data order so you'd probably have to access it though vertex index, though I'm not really sure how or if that data is exposed to the graph editor yet. $\endgroup$ Jul 2, 2021 at 12:26
  • $\begingroup$ I concur, it's not possible to do that for now $\endgroup$
    – Gorgious
    Jul 2, 2021 at 12:59
  • 1
    $\begingroup$ Agree that not possible-- but sometimes, you can do what you want by getting the data in via other modifiers or other techniques before the geo nodes. For example, if you want the Y position of some different vert, you can bake world pos to image, organize UV appropriately, and then read a particular UV. $\endgroup$
    – Nathan
    Jul 2, 2021 at 15:58

1 Answer 1

1
$\begingroup$

You can access other vertices values. The problem is, those vertices aren't organized into a 2D array of v(x,y). They are organized into a 1d array of v(index).

Now, in some cases, you know how Blender is organizing those vertices, or you can figure it out, and so you could kind of reverse engineer a 2D array out of those indices:

enter image description here

By separating out this grid by index, we can see that Blender builds the grid from -Y to +Y, then from -X to +X. If we'd like to access a particular part of this grid by X,Y, we can figure out that its index is basically equal to y+10x. Those numbers come from the fact that we have 10 vertices per step, spanning 1 Blender unit. (Not taking into account the scaling or centering.)

In your example, on this grid, to access V(x-1,y) you'd access index -10, and to access V(x, y+1) you'd access index +1. However, those are specific to this particular grid mesh. On some other mesh, we're not going to have the same indices. If we take a plane and subdivide it, then look at how the indices are ordered, we see:

enter image description here

However, we can also use a "sort elements" operation on meshes to order their indices however we'd like. By making a quick shapekey to shear it, then using a sort elements by view X, I can control how its vertices are ordered, and once again, knowing the vertex count per axis, I could reverse engineer a 2D array out of its 1D index:

enter image description here

$\endgroup$
1
  • $\begingroup$ Love that reverse engineering ! +1 $\endgroup$
    – Chris
    Jan 29, 2022 at 4:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .