2
$\begingroup$

I have a high-level challenge I'm trying to work out, and feel I'm very close but missing some Geometry Nodes knowledge to get what I want out of it, and would really appreciate some help or direction.

The goal is to take an object consisting of a 'cloud' of unconnected vertices, each with a custom attribute value on them, and create a 3D graph that groups the points into a grid and assigns height based on this custom attribute, summed for each point in the grid square.

For some background I'm using this script to convert a csv file into the vertex cloud: https://blender.stackexchange.com/a/241870/76672

This is my starting point, with the custom attribute being 'scaleVec': enter image description here

I can easily turn this into a bar chart by instancing cubes on each point and moving the bottom face, but the issue is the bars will often overlap, so I want to have a grid underneath that groups points near each other and shows the amount by summing the number of points, or the combined value of the attributes.

This is a top-down view showing an example point distribution over a small grid (3 points over the green square, 1 over the blue, 1 over the red, and none over the yellow):

enter image description here

and the expected result:

enter image description here

I have been trying to use Raycasting from the points downwards onto a grid in Geometry nodes, as well as the Attribute Statistic node to sum attributes, but I'm getting a bit stuck, and if anyone is up for giving me some pointers for this challenge (im using Blender 3.1) Id really appreciate :-)

$\endgroup$

2 Answers 2

2
$\begingroup$

Here is my solution (for demo reason, I distribute random points and weight is 1 everywhere):

enter image description here

How it works:

To sum all weights, I use accumulate field node. Coordinates of each point is rounded and x is multiplied by 10, so that I can get a unique ID of each square:

enter image description here

When I just set position to rounded one and instance cubes

enter image description here

Last step - remove duplicated points:

enter image description here

$\endgroup$
2
  • $\begingroup$ Thanks, thats great, I have tried adding a value to control the resolution of the underlying grid, that has to affect the floor, positioning, cube size etc, I was wondering what is the value for the 'Multiply' node based on? is it 10 mainly because of the grid size that you set up to test or is it relative to the cube size, floor etc? $\endgroup$
    – awnine
    May 2 at 21:58
  • 1
    $\begingroup$ It is just to give a unique number for each bar group. Each line contains 10 bars. $\endgroup$
    – Crantisz
    May 3 at 7:26
3
$\begingroup$

Following, I will explain two different solutions.

Solution 1: Instantiate bars on points based on proximity to the instantiation point

This one is similar to the one of Crantisz, but works a litte different. Instead of calculating grid squares, it creates a grid and uses proximity functions:

Node setup

bars

It starts with setting the ID of each point in the cloud to the index of the nearest point in the target grid.

Setting the ID

Next it sets the position of every point in the cloud to the nearest raster point and stores the count of points at this position directly at those points.

Save the count of points

Finally it merges the points by distance and creates the bars in the appropriate size:

Creating the bars

Dynamic Version

And here is a dynamic version of solution 1:

result dynamic

Solution 2: Extrude Faces based on proximity to face

This solution starts with some points on some faces. It then counts the points per face by proximity and extrudes the faces based on this count. You may plug in any object.

Node Setup Solution 2

Result 1, Solution 2

Result 2, Solution 2

Result 3, Solution 2

How does it work?

It starts with creating points on the faces of the object, defined by the input parameters. Then it iterates over those points and calculates the number points per face index. This value is stored at every point by the Capture Attribute node together with the related face index in the ID of the point. Now every point knows, to which face it belongs and how many points belong to this face.

Calculate number of points per face index

Finally, we would like to iterate over all faces and read the number of points from one of these points. We can do this by reading the captured attribute from the nearest point to the current face. But this will not work, if there is no point. In this case, we would get a foreign point instead of none.

To get around this, we place the points on the origin of their faces and merge them by distance:

Place points on origin of faces

Now we have zero or one point on the origin of every face. And the point knows, how many points belong to the face. This allows us to iterate over all faces and grab the point count from the nearest point to each face. If the distance to this point is greater than 0, this means, that there is no point. To prevent issues in some cases, we will have to check for > 0.001.

We use this value to define the scale of the extrusion of the related face.

Extrude the faces

$\endgroup$
3
  • $\begingroup$ Thank you, I will try this one out too... would this technique work better (with modification) with an irregular sectioned plane (ie one split into quadrants, or triangles) instead of a grid? I had experimented with raycast in order to use this on such a shape as mathematical functions wouldn't work as well on it, perhaps i should formulate it into another question if its a large modification $\endgroup$
    – awnine
    May 2 at 22:17
  • 1
    $\begingroup$ It depends on the shapes and on their regularity, because the points are assigned to the bars by their distance to the instantiation points. Anyway, I could imagine a similar solution, that could work. If I find some time, I will try tomorrow. $\endgroup$ May 2 at 22:25
  • 1
    $\begingroup$ @awnine, I added another solution to my description, that should work with every type of plane. $\endgroup$ May 3 at 19:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.