1
$\begingroup$

Everything is filled with cubes, but spheres also appear among them. I would like the cubes around a sphere to be removed.

enter image description here

enter image description here

Questions:

  1. How can I create a setup where the cubes are removed?

  2. Is it possible to create multiple setups and have each one appear randomly? (I marked the setups with crosses.)

  3. How can I prevent spheres from appearing near other spheres, within a radius of 2 cubes along the x, y, and z axes?

Additional questions

  1. How can I replace the removal with a radius of 1-2 meters? (I highlighted this in a box.)

  2. Is it possible to place other objects where the cubes have been removed?

I use Blender 4.2.1

$\endgroup$
4
  • 1
    $\begingroup$ (1) Is Q2 about the red X crosses ? (2) Are cubes and spheres always spawned on a 2D Cartesian grid ? (3) In Q3, is "radius" referring to the step of this grid ? (4) In AQ1, a radius is mentioned, but a rectangle is drawn. How to understand this distance ? (5) In AQ1, how is defined the "1-2 meters" distance ? Is it a multiple of the grid step ? (6) In AQ2, do you want to replace ALL removed cubes with an object ? (7) In AQ2, do you want to replace removed cubes with the SAME object ? Or with DIFFERENT objects picked in a collection ? $\endgroup$ Commented Aug 30 at 7:31
  • $\begingroup$ Hi, thanks for the response! I've uploaded another screenshot. Spheres appear in place of cubes, and around the spheres, there can be either objects or empty spaces. For example, when I click on Seed (Random Value), the spheres change their positions, and different setups, like those marked on the screenshot, appear along with them. (Some spheres appear with a specific setup and must have the exact collection and object positions I've specified; others can have different objects from the collection; and some might be empty.) + probability of appearing. $\endgroup$
    – user200123
    Commented Aug 30 at 10:20
  • $\begingroup$ They should be spaced 2 cubes apart, or even by meters (I’d like to see both options). I’ve circled in yellow how it shouldn’t be, and in red how it should be (+ if possible, it would be great to show a specific node setup for spacing by meters, meaning several cubes). 3D Collection. $\endgroup$
    – user200123
    Commented Aug 30 at 10:20
  • 2

1 Answer 1

3
$\begingroup$

(Using Blender 4.2.1)

Approach and results

Two collections are defined, one with the different patterns of points around a sphere (see next figure right side), one with the different objects to spawn on a grid (see next figure left side). The location in the grid of a pattern center is randomized using a Distribute Points on Faces node whose Distribution Method is set to Poisson Disk to avoid overlaps. Patterns are used to delete points around a sphere, to instance the same object around a sphere, and to instance different objects around a sphere. This behavior is also randomized.

Results

Resources


(Blender 4.2.1+)


GeometryNodes modifier

Overview

GN Main graph and input parameters

Scene setup:

  • Grid: default object to which the GeometryNodes modifier is attached.
  • Patterns: collection of the different patterns. Each is made from a 3x3 grid modified in Edit Mode to delete the central point, as well as some border points. Duplicating a pattern increases its probability to be spawned. The size of this collection is managed dynamically. Order in this collection is irrelevant.
  • Objects: collection of the different objects to spawn. Duplicating an object increases its probability to be spawned. The size of this collection is managed dynamically. Order in this collection is crucial. Consequently, names are edited to enforce the alphabetical sorting.
    • Object of index 0 is never spawned. It is used to mark where grid points are deleted.
    • Object of index 1 is the object spawned everywhere initially.
    • Object of index 2 is the object spawned at the center of a pattern.
    • Objects of index 3 and more are spawned at the border of a pattern. Consequently, this collection must contain at least 4 objects.

GN input parameters:

  • Count: number of rows and columns of the grid (minimum 3).
  • Distance: Minimal distance between the centers of two adjacent patterns.
  • Density: Factor controlling the probability to spawn a pattern at a grid point position. Too large values are ineffective once the grid is fully packed based on the minimal distance.
  • To delete: Factor controlling how many pattern points are deleted before spawning objects. 0 yields no deletion. 1 yields no spawned objects.
  • Sameness: Factor controlling how many patterns are made with the same object. 0 yields random objects everywhere. 1 yields the same object per pattern.

GN main graph:
The main process is made of 3 steps coded as Group Nodes:

  • Grid Setup: initializes the grid and where patterns would be spawned.
  • Pattern Setup: randomizes each pattern behavior (deletion, same object spawned, different objects spawned).
  • Grid Filling: spawns objects on the grid according to the patterns.

Grid setup

Initialization of the grid and where patterns would be spawned: GN graph with distribute points on faces node Dark red nodes:
1. The step of the Cartesian Grid is 1. So its width and height are 1 less than Count, its number of rows and columns.
2. The attribute stored in Point domain named "type" is set at 1, the index of the object spawned everywhere initially.
Dark green nodes:
3. To not spawn patterns centered on the grid border, interior edges are flagged as True by counting how many faces they belong to. Border edges are connected to only 1 face ; interior edges are connected to 2 faces.
4. This flag is transferred from the Edge domain to the Point domain using a Capture Attribute node. "Averaging" of boolean values is such that this flag is True at a point if and only if it is True for all the edges connected to this point. So it is False for all the points along the grid border.
Dark blue nodes:
5. There is no node to distribute points on points randomly. Consequently, a Distribute Points on Faces node is used instead. Setting its Distribution Method to Poisson Disk combined with the Distance Min parameter is the way to randomize positions on the grid with a constraint on how these are spaced. How many patterns would be spawned is controlled by the Density Max parameter. To create different cases, the Seed can be animated with the active Frame number.
6. It is to notice that points generated at step 5 are almost never colocated with grid points. So they are moved using a Set Position node. Their new location is recovered from the nearest grid point with a first Geometry Proximity node.
Dark pink nodes:
7. The "type" of a grid point colocated with a pattern center is updated using a Store Named Attribute node whose Selection mask is checking the distance between this grid point and the nearest pattern center, returned by a second Geometry Proximity node. Border grid points are excluded at this time.
8. The "type" is set at 2, the index of the object spawned at the center of a pattern.
Dark grey nodes:
9. Patterns are spawned centered on the points updated at step 6 using an Instance on Points node. Border grid points are excluded once again. Activating the Pick Instance parameter, successive patterns are picked from the Instance collection.
10. Instances are recovered as separated objects from the collection "Patterns" using a Collection Info node with the parameter Separate Children checked. The world position of each pattern is irrelevant because the Reset Children parameter is checked also.

Pattern setup

Randomization of each pattern behavior: GN Graph to chose behavior of each pattern Dark green nodes:
1. The default behavior of a pattern is to spawn the same object at each of its vertices, yielding homogeneous patterns. The index of this object inside the collection "Objects" is drawn randomly from 3 (because objects with index 0, 1 and 2 are reserved for specific tasks) up to the last object in the collection.
2. This last value is computed as 1 less than the collection size, recovered through a Domain Size node set in Instances domain. To get it right, the parameter Separate Children of the Collection Info node must be checked.
3. The Seed of the random process is animated with the active Frame number.
Dark pink nodes:
4. The object with index 0 is attributed to grid points to be deleted. A Boolean probability is drawn for each pattern, controlled by the input factor "To delete", and by the active Frame number. It is to notice that this number is arbitrarily offset by 100 to unsynchronize the successive random processes.
5. A Switch node is inserted to explicitly convert True values to 0, and False values to 1. A Multiply Math node is then used to nullify, or to keep unchanged, the object index drawn at step 1.
Dark red nodes:
6. Objects spawned on patterns with negative object index are randomized, yielding not homogeneous patterns. A Boolean probability is drawn for each pattern, controlled by the input factor "Sameness", and by the active Frame number. It is to notice that this number is arbitrarily offset by 200 to unsynchronize the successive random processes.
7. A Switch node is inserted to explicitly convert True values to 1, and False values to -1. A Multiply Math node is then used to keep unchanged, or to make negative, the object index drawn at step 1.
Dark grey nodes:
8. Eventually, an object index (positive, null or negative) per pattern is stored as an attribute named "type". It is to notice that the Store Named Attribute node is set in Instance domain.
9. To get the final position of the vertices of each pattern, and to propagate the attribute "type" from Instance to Point, a Realize Instances node is used.

Grid filling

Instantiation of objects on the grid according to the patterns: GN graph to spawn objects (to be documented...)

Discussion

$\endgroup$
0

You must log in to answer this question.