# Controlling the density of individual objects from a collection info node

In geometry nodes I made two layers of cylinders containing two objects: icospheres and cubes. Both objects are added to the two layers through a collection info node:

Blend file: GN - layers test 3.

Currently, the density of the icospheres and cubes is jointly controlled from the distribute points on faces node. How can I control the density of the icospheres and cubes that come from the collection info node separately? I know I can split groups from the collection info node, but then the icospheres and cubes are already mixed.

Update of the blend-file (see my comment @Hulifier below): GN - layers test 5

Geometry Nodes:

The total density is the sum of the two densities.

The probability of a point being a sphere is the sphere density divided by the total density.

$$\text{For N Instances}$$

What this does is, first create a mesh line with an edge count equal to the object count in the collection, then it uses the density values to set the length of the edges, while keeping them stacked in a line. With this done, it generates a random with the interval $$[0, S]$$, with $$S$$ being the sum of all densities. The random is then used as a vector to get the nearest edge's index, which will be the index for picking an instance.

For every object added to the collection, you will need to add another Index Density Node Group to the node chain and connect the last sum to the Density Max socket of the Distribute Points on Faces Node.

The index of a density doesn't need to be specified since the chain of Index Density Nodes already calculates it, starting with 0 and adding 1 for each node.

You should also rename your objects in the collection since the index of objects inside comes from the alphabetical ordering of their names. That way, adding a new object to the collection will not change the index of the others.

Also, if you rename an object inside the collection, the index order will not update, for updating it, you just drag an objet which is inside the collection to the same collection.

Another thing is that some of the small cyllinders sometimes disappears, this is due to the distance from the bigger objects changing, this can be solved by calculating the distance to the objects before transforming them.

Here the transformation is done to the instances, not the points:

The instances before the transformation are the ones sent to proximity calculation.

## Update with using normals

For using normals of the deformed plane while using the original position to generate points, we capture the normals from the deformed plane to the original, we will also capture the position. Doing this, points are generated in the original mesh, but they hold anonymous attributes with the deformed position and normal, which we then use to set their position and rotation.

• This works great with two objects! Tnx a lot! :) It seems to get more complicated when there are more than two objects in the same collection, because the boolean is only true or false. Know a way to control it with more than two objects? Or do I have to add them in that case individualy by an object info node?
– EwSa
Commented May 25, 2022 at 19:24
• @EwSa I added to the answer a way to use more than two objects of the collection. Commented May 25, 2022 at 22:35
• You are realy amazing!!! I could never ever find this out with the skills I have at this moment. I hope I can solve problems like you for once :) Tnx a lot!
– EwSa
Commented May 26, 2022 at 7:41
• Hope you can help me with one more thing. In the file, you see I use a geometry proximity to delete the litte cylinders in each of the two layers where the floating objects are insterted. The noise of the layers is driven by the "#frame" command. When I start this noise animation, the position of the little cilinders are recalculated around the floating objects and they sometimes disappear, because of the geometry proximity. Also the floating objects are "jumping" around the layer. Is there a way to prevent the "disappearing" and "jumping"? New blend file updated in my post above.
– EwSa
Commented May 26, 2022 at 20:35
• @EwSa Edited the answer with the solution to the proximity problem that was making some instances disappear. Also, the total sum should be connected to the Density Max of the Distribute Points on Faces node, and I forgot to do that, sorry for that. I updated the images and the blend file. Everything seems to be working fine for me now. Commented May 26, 2022 at 20:41