0
$\begingroup$

I have tried to implement the advice from a previous question, combined with controling the density of each instance on points. However, I still can't quite figure it out. I have done the following:

The basic setup is one layer consisting of cylinders and cubes. I started with an auto indexing using a mesh line to give al objects a specific index, after which I want to regulate various attributes of each object within the collection separately. In this example I want to translate the cylinders and cubes, up and down and later on delete some of them.

enter image description here

Total node tree:

enter image description here

Part of the node tree that explains the control of the density:

enter image description here

Overview of the node tree of the group inside the "control frame" with unique index to control attributes of individual objects (in this case the position of the density and the translation):

enter image description here

Blend file:

For now I'm able to control the ratio of the density of both the cylinders and cubes. Now I want to control the translation of both objects with the same unique index as for the density. However, when I translate the cylinders inside the "cylinder frame", the cubes go up. Inside the "cube frame" the translation is not working. What is wrong with this setup?

Update: Ok, I'm one step further. There has to be a way to get this to work.

I have added a sphere within the collection and also created a frame for the sphere with an index group.

enter image description here

Regulating the density in each frame works. However, within the frame of the cylinder I control the translation of the cubes and within the frame of the cubes I control the translation of the spheres. The translation in the frame of the spheres does not work at all.

So I've found that it's the translation indexing that is out of sync with the density indexing. If I set the index on the equal node within the index group and set the B value of this equal node to 0, then I can move the cylinders. In that case however the auto-indexing is no longer working for the translation and I lose control over the cubes and the spheres (see gif below).

enter image description here

Blend file:

So, it probably can be resolved with some math node(s), but I can't figure it out. Can anyone help me with this part?

$\endgroup$
2
  • 1
    $\begingroup$ Hello ! I seem to understand you're using the node group as a loop, that goes back and acts on the next instance that's passed to it, is it the case ? (spoiler : it's not possible) $\endgroup$
    – Gorgious
    Jun 7, 2022 at 10:11
  • $\begingroup$ Thanks for your reaction. It must be possible, see my update. $\endgroup$
    – EwSa
    Jun 7, 2022 at 20:19

2 Answers 2

4
$\begingroup$

enter image description here

The reason for the one index offset when translating is because the node group's $\text{Auto Index}$ starts at index $1$:

enter image description here

This is for letting the position of the Mesh Line's first vertex at zero (if the line start position is $0$, and it needs to start at $0$ so the randon index using probability works correctly), since the first edge needs to start at $0$ and end on the density of the first instance.

To make it work with the instance translation, you will need to subtract one from the $\text{Auto Index}$ before comparing with the instance index:

enter image description here

Or you can set the default to zero, use the $\text{Auto Index}$ for the instances, and for the line you use the $\text{Auto Index} + 1$. Doing it this way will economize one node, since the value $\text{Auto Index} + 1$ is already used for calculating the next index.

enter image description here

Note: When Changing the default value of the node group, you will need to delete the node and then readd it (Duplicate won't work), this is because node groups doesn't update default values on nodes added before the change.

Edit:

After doing some modifications, the execution time seems to be a little smaller. I tested with eight different instances, the time difference was almost nothing, but maybe it could become bigger with more.

enter image description here

Index Properties node group:

enter image description here

End Properties node group:

enter image description here

With this modification, you won't need more to use the sum of densities for the Max input of the Random Value node, the value needed is now $1$.

$\endgroup$
3
$\begingroup$

The question can be understood as:

How can I control the distribution of an extensible number of objects from a collection with a given probability and transform them group-wise?

Note: The main difference from the other solution posted here is that control of the distribution of points lies entirely with the node Distribute Points on Faces, and it is not the probability of distribution set in the objects that affects the number of points. ...which just sounded more plausible to me.

Two things are necessary for this:

  1. A cascadable node group, which can be connected arbitrarily in series.
  2. A mechanism that translates the probability or weight defined in these groups to the number of distributed points.

I arrived at the following solution:

enter image description here

Cascadable Node Group

The first group is a cascadable node group used per object. It allows setting a probability for instantiation, as well as transforming a specific object in the collection.

enter image description here

The node group has the following inputs, which are modified and provided again as output:

  • Segments
  • Sum
  • index
  • Instances

In addition, there are the following fields for control:

  • Propability
  • Translation

enter image description here

Segments

Here, a mesh line is simply created. The starting point is the sum of all previous values, and the end point is the addition of the sum and Propability. So I draw a line consisting of two points, which starts exactly at an existing line.

I then convert this into an instance with Geometry to Instance, and add it to the group of segments with Join Geometry.

Each node group thus adds a line whose length corresponds to the value you specify with Propability.

Sum

This is the sum of the values given by the value for Propability of each group. All other groups after this one, again use this value as a starting point.

Index

This is an integer value incremented in $1$ increments, each of which is used to select and transform a particular object in the collection.

Instances

Here, the instances from the collection are simply passed so that they can be transformed individually.

Translating to Index

The next node group deals with translating the previously determined probability of an instantiation into an index.

enter image description here

It has only two inputs:

  • Distributed Points
  • Target

In the output, this node group returns the distributed points, but the attribute ID has been added, which now contains the indexes for the instantiation as values.

enter image description here

Distributed Points

The object that contains your distributed points, in this case the output of the Distribute Points on Faces node.

Target

This input receives the group of segments previously created by the first node group.

By saving the index of each instance with the Attribute Capture node in the first step, and then converting the instances back to lines with Realize Instances, I get back their original index.

Since we know the number of distributed points with the node Domain Size, we can now scale the consecutively threaded lines all together in such a way that their dimension corresponds to the highest index value of the distributed points.

As you show in your example, I then use the node Random Value, which I use as Source Position in the node Transfer Attirbute.

This now returns a certain value from the Nearest Edge.

However, I'm fishing out the previously captured original index of the segment, ...and that's exactly what we need here in the end.

So that I can use this value comfortably outside of this node group, I save this into the ID of the single points.

Overview

So in the last step I just have to put the previously supplied ID into the input Instance Index of the node Instance on Points, and you get a distribution of objects from a collection, with the previously supplied values.

enter image description here

PS: I would request you to adjust the title as well as the content of your question according to what your concern is. Personally, it was quite difficult for me to figure out what you actually want to achieve.

$\endgroup$
0

You must log in to answer this question.

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