1
$\begingroup$

Let's say I have a simple Mesh Line and use the Instance on Points node to make an instance of a given object on every point of the line. How can I decide for each individual point if it should have an Instance. I know the Instance on Points node has a selection input and I could use the Index input with some math/compare. But that way I would have to add/remove nodes if I would change the point count of the line. What I would like to have is a kind of "boolean list input", i.e. (0,0,1,0,1,1,0) or something similar so that I could specify for each whether there should be an instance or not. Is that possible with geometry nodes?

And how can I access/modify the selection input field of the Instance on Points node with python? enter image description here

$\endgroup$
1
  • $\begingroup$ The simplest approach would be to generate the line by some other means, possibly by had, and only have vertices where you want instances. They don't have to be equally spaced. $\endgroup$ Commented Jan 12, 2022 at 1:10

2 Answers 2

3
$\begingroup$

Maybe I'm missing something, but if you "would change the point count of the line", this wouldn't affect the vertex order, and so it wouldn't affect the indices on the line? Seems irrelevant to the problem, then. As for specifying some arbitrary input, you could use a string, except in Blender 3.0 you can't use Index to control String Slice, as the parameters are supposed to be constant:

However, you can use an integer input:

Homework

Since an integer $005$ is the same as integer $5$, in order to see leading zeroes, you need to start each number with $1$ and ignore first index.

Since it's not chad Python integer without length limit, but instead virgin C++ signed integer with range $-2147483648..2147483647$, You can only get get 10 digits, however, due to a conversion to float it gets worse: Blender uses float32, which after reaching $2^{24} = 16777216$ drops its precision and rounds to increments of $2$:

>>> import numpy as np
>>> np.float32(111111111)
111111110.0

Since $100000000 > 16777216$, the last digit can no longer be odd like $1$, therefore the maximum number of digits is $8$, and due to necessity of adding $1$ in front, only $7$ digits will carry data. This just can't be. Solve this by changing the base to $2$, you can use something like Windows calculator in programmer's mode, or type in Python console 0b in front of the binary number, to see what's the base 10 integer for it, or use a custom string property and a driver like this:

Homework done by Gorgious

It sounds condescending so let me clarify he figured it out independently and had a smarter approach of just comparing powers (kind of like comparing password hashes) rather than reversing the powers (logarithm). His setup works for any base so I modified it for base 2:

Now you can use a driver like so:

int("111011011001"[::-1],base=2)

>>> bin(16777216)
'0b1000000000000000000000000'

There's 24 zeroes, which means you can store up to 24 booleans this way.

Using another geometry

You could simply create a plane, remove an edge (with verts), subdivide the other edge (you could subdivide it more than needed), enable MeasureIt addon and show the debug overlay with vertex indices, Mesh > Sort Elements > View X Axis, select vertices, zoom in at the beginning and just select the vertices you want to enable and raise them up from Z=0 to anything else:

Use increment snapping to easily return vertices to 0. Use a Python script to import data from external source by assigning coordinates to vertices.

Parsing a string

Just found a way to parse a comma/space separated list and wrote an answer here:

Geometry Nodes - Extrude edge by ID

$\endgroup$
5
  • $\begingroup$ Oh and you can pass data in different ways too, like by using some geometry for example... $\endgroup$ Commented Jan 8, 2022 at 21:12
  • $\begingroup$ Thank you for your response. Changing the base to 2 would increase the possible positions to 32 since it is a 32-bit integer. Unfortunately, I'll also have cases where that's not enough. But at least a good starting point. It's a shame the Slice String node doesn't take the index as input. $\endgroup$
    – KevinR
    Commented Jan 10, 2022 at 10:34
  • $\begingroup$ @KevinR what about controlling with a mesh? You can have an edge, subdivide it to get as many vertices as many instance-offsets you want to have, and on each point you want to spawn an instance, just change the vertex Z to 1. Now you can use the vertex Z coordinate to control if an instance should spawn... $\endgroup$ Commented Jan 10, 2022 at 10:37
  • $\begingroup$ Hmm, in that case I would need the same selection to control the Z coordinate of the specified verticies procedurally, or am I missing something? $\endgroup$
    – KevinR
    Commented Jan 10, 2022 at 11:15
  • $\begingroup$ @KevinR see edit. $\endgroup$ Commented Jan 12, 2022 at 10:24
0
$\begingroup$

In Blender 3.0 to randomize the instance on any points you can use Random Value node with Boolean type input to Transfer Attribute node, and target should be the one points generating geometry. Output of Transfer Attribute node attach it to Selection in Instance on Points node.

Now have fun by changing Probability value and Seed value

enter image description here

$\endgroup$
1
  • 1
    $\begingroup$ I don't think the OP is interested in randomization. He clearly states he wants to decide which points of a mesh line to display, based on some "bulk" input. $\endgroup$ Commented Mar 11, 2022 at 21:31

You must log in to answer this question.

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