Getting normals for duplicated, re-seeded geometry-node instances

In this question I get an answer to re-seed duplicated instances within geometry nodes. Although this works well for a plane, it causes problems with the orientation of the instances when using a sphere as a base geometry. Due to the used shuffle index groups, the instances lose their orientation along the normal. I think this is because of the used random value node inside each shuffle index group.

Geometry node tree of the Shuffle index group:

The original layer has no problems:

The instances of the duplicated layer, however, don't follow the normal:

I've tried to transfer the normal with a transfer attribute node but without succes. My question is simple: how do I make sure that the instances continue to follow their normal, after they are re-seeded?

The final result should look like this (in this example the inner instances in red are not re-seeded):

• I don't understand why shuffling instances is that much more computationally efficient than genuinely 'reseeding', with a brand new random selection. Is this something you have experienced? Commented Jun 20, 2022 at 20:22
• The actual geometry tree is much larger, making it more cost effective to do it this way than to create a new random selection. I've now made a simplified version of the geometry tree to isolate my problem and clearly state what I'm running into.
– EwSa
Commented Jun 20, 2022 at 20:54
• Random number generation is quite costly, but shuffling requires as much, if not more, than a clean sheet. If you really want to save clock-cycles, perhaps you could fake the randomness. For instance, in this particular illustration, you could just rotate the inner sphere.. nobody could tell. Commented Jun 20, 2022 at 21:08
• Tnx! Nice solution :-) The point is: I want to make it procedural and switching between different base geometries. The sphere and plane are just examples.
– EwSa
Commented Jun 20, 2022 at 21:13

Since there's no 'Set Rotation' or 'Rotation' node, we will need to set the rotation of the instances after branching the the layers.

First, the rotation is captured or stored in the original layer as an attribute. For the original layer the rotation just need to be connected to the Rotate Instances node. For the shuffled layer the rotation needs to be set after shuffling, transferring it from the original with the rotation captured.

With Capture Attribute:

• Thx! Can't try your solution. Blender 3.2 crashes when setting the store named attribute on vector instances. More people experience this.
– EwSa
Commented Jun 21, 2022 at 19:53
• @EwSa I edited to the answer the Capture Attribute equivalent method. Commented Jun 21, 2022 at 20:26

First thing that comes to mind is... Why even use the Robin Betts' solution for shuffling geometry? It looks like you're spawning cuboids, spheres, cylinders. You can just "pick instances", and connect a Random node to an instance index. You could use a different seed for each "layer". Only use the Robin Betts' (or any other in the thread) solution if you need a transition between those instances.

Your problem is caused by instances rotating once, when spawned on a sphere before shuffling. After shuffling the instances are moved, but they still have old rotations. You could transfer the rotation from an old instance at the same spot, or you can just rotate the instances near the end, as in your case it's quite simple what a normal is - it's a sphere, so a normal is the direction from sphere's center to self, i.e. it's the position (pedantically speaking, you'd need to normalize position, but the Align Euler to Vector doesn't expect a normalized vector):

Remember to remove the rotation at the beginning: