3
$\begingroup$

I have a mesh that contains more than 100 mesh islands and 10 groups, each containing 100 collections of assets that I want to array to these mesh borders. I use the Switch Index Node to get the combination options of the instance.

I'm trying to get the random options for the combination that was instanced to each mesh island instead of a specific option for all islands. But the switch index seems like don't work with random node.

enter image description here

enter image description here

Let's take a look at a simple example with a mesh that contains 3 islands: enter image description here And 3 groups with 7 collections of instance:

  • Group Blank: 1 collection
  • Group A: 3 collections
  • Group B: 3 collections enter image description here

The current node setup just gets a specific combination index (1-1-1, 1-2-1, 1-3-2,...) for all islands. enter image description here

Have any idea how to get the random combination index for each island?

Like 1-1-1 for island 1, 1-2-1 for island 2, and so on. enter image description here

Remember, this will be used to address a mesh with over 100 islands and 10 groups, each containing 100 collections.

I don't want to make the combination options of these collections manually. So using the random method will be helpful.

Get more details from the example blender file (Version 4.3) below.

$\endgroup$
3
  • $\begingroup$ You'll have to find another way than with Index Switch : it expects a single-value (one value for all geometry), whereas you are trying to feed a different value for each point. I think it could be achieved with a For Each zone, maybe even without a looping zone. I'll try something when I can. $\endgroup$
    – Lutzi
    Commented Dec 11 at 15:42
  • $\begingroup$ Are you using curves in your real problem with 100 collections? I can provide a solution using For Each Element zone, just need this little clarification. This is what I got. $\endgroup$
    – Danya K
    Commented Dec 11 at 23:30
  • $\begingroup$ Yes, @DanyaK. All mesh borders are orthogonal curves and the example mesh is a real imported mesh that needs to be addressed but is small. $\endgroup$ Commented Dec 12 at 2:49

2 Answers 2

3
$\begingroup$

The problem you are facing is that a Random Value node will have a "field" output if ID or Seed are also "fields". You need to apply a constant value to both inputs to get a constant output.

The idea I am going to demonstrate can be described as follows:

  1. Interact with each spline separately using a For Each Element zone.

  2. Randomize each collection independently of each other and independently of the spline groups:

  • For each Random value node, the ID is set to the ID of each spline to ensure that the values ​​are independent for each "spline".

  • Each Random value node has a different Seed value to ensure that all random nodes are independent of each other. To do this, I simply add 1 to each Seed of the next node

  • Finally, I multiply by the number of collections of the input Seed to make sure there are no dependencies of Random Value nodes ​​for different input seeds. Why do this? Let's assume like in the example you gave that there are 3 collections. Now, for the first spline (ID = 0 for each Random value), if I didn't use this multiplication: For Seed = 0 seeds are (0, 1, 2). For Seed = 1 seeds are (1, 2, 3). So 1 and 2 will be repeated again for Seed = 1 for the same spline. You might not even notice this, but I wanted to also get values ​​independent of each seed, so I do this multiplication. So what I did was: Seed = 0 : 0 times 3 = 0, seeds are (0, 1, 2). For Seed = 1: 1 times 3 = 3, so seeds are (3, 4, 5). No interference now.

Note: if you know you have 100 collections, you can just multiply Seed by 100 directly, then there is no need to use Domain Size.

My only concerns are:

  1. Are they really independent? I think so, but maybe not, maybe I'm missing something.
  2. The For Each Element zone is "quite slow", overall I wouldn't recommend using it if you can avoid it. Only use it if it doesn't have a huge impact on performance or you really can't solve the problem without it.

The entire code block:

Result:

]

New contributor
Danya K is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.
$\endgroup$
4
  • $\begingroup$ I think OP actually wants to use fields. $\endgroup$ Commented Dec 12 at 15:22
  • $\begingroup$ @MarkusvonBroady do you mean fields for random nodes? I'm just not sure what you mean. $\endgroup$
    – Danya K
    Commented Dec 12 at 15:40
  • $\begingroup$ Actually maybe I'm wrong, maybe you understood his question better. $\endgroup$ Commented Dec 12 at 16:59
  • $\begingroup$ Thank you, @DanyaK. I appreciate your help. I'll try to add this to my complex node setup. $\endgroup$ Commented Dec 12 at 20:02
3
$\begingroup$

A proper solution is to join all objects into a single group, then use "pick instances" to pick the right one, based on some mapping:

Imgur mirror (SE image hosting has problems)

Tested on:

Imgur mirror

Result:

Imgur mirror

$\endgroup$
1
  • $\begingroup$ Thank you, @Markus. $\endgroup$ Commented Dec 12 at 20:03

You must log in to answer this question.

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