Attraction distance - branches that are within this distance (and outside the kill distance) of an attractor will grow towards that attractor.
Kill distance - how close branches can grow to attraction nodes before stopping.
Segment length - length of each branch segment of the generated structure. In each iteration of the simulation, one segment is added to the tips of each branch that is not within a kill distance of an attractor.
Branch rendering
Material - reference to a material object that is applied to each individual branch segment.
Enable vein thickening - progressively increase the radius of each branch segment starting from the tip (smallest) to the root node (largest).
If enabled ...
Minimum radius - smallest thickness that a branch can get.
Maximum radius - largest thickness that a branch can get.
Radius increment - rate at which the radius changes across each branch segment from tip to root.
If disabled ...
Radius - constant radius for all branch segments.
Attractor generation
Attractor placement - dropdown with the following options:
SPHERE
Radius - radius of sphere.
Attractor count - number of attractors to scatter.
GRID - evenly spaced attractors on a grid.
Dimensions - length, width, height of grid.
Resolution - number of attractors per axis.
Jitter - amount of random displacement per attractor to make them less uniform.
MESH - scatter attractors on the surface or inside of a custom mesh.
Target mesh - reference to the mesh you want to use.
Raycasting attempts - number of times to try casting a random ray. Unity's collision detection is not perfect, so the actual number of attractors that are generated will be much less than this number.
Raycasting direction - direction to fire random rays for attractor placement.
INWARDS - casts random rays from outside the mesh towards the origin. Scatters points on the surface.
OUTWARDS - casts random rays from the origin to the outside. Scatters points on inner surface.
DOME - casts random rays in a hemisphere around the mesh.
Attractor gizmo radius - size of the editor gizmos that indicate the position of each attractor.
Actions
Generate attractors - attempt to place attractors using the parameters chosen above. This may take a while depending on the parameters chosen and the complexity of the mesh.
Clear - remove all attractors from the scene, like a reset.
Root node(s)
Type of root node(s) - dropdown with the following options:
INPUT
Root node object - reference to the point object you want to use as a root node.
MESH
Target mesh - reference to the mesh you want to randomly place root nodes on.
Number of root nodes - how many randomly-placed root nodes you want.
Bounds
Use bounds - enable or disable restriction of branch growth to a chosen bounding volume.
If enabled ...
Bounding mesh - reference to a mesh object you want to use to constrain growth inside of.
Obstacles
Use obstacles - enable or disabled the use of obstacle objects that branch growth cannot occur in.
If enabled ...
Size - how many obstacles you want to use.
Element [n] - reference to a mesh object that the branch growth must avoid.
Run controls
Iterations to run - number of times to run the simulation. Start small until you know what you're doing!
Run - press to run the simulation for the number of times chosen above.
Reset - press to remove any previously-generated branches so growth can start over.
Export
Filename - name of the file you want to export. Be sure to provide a file extension.
Export - press to export the generated branches on the screen to a file with the name provided above.
Right now, a crude Inspector UI is exposed by just setting some key parameters as public. This requires some intimate knowledge of the inner workings of the code, and doesn't do a great job of handling the conditional parameters associated with different modes.
Currently, each time a branching point is reached (that is, when there are two or more children on a node), the "starting" branch/tube is terminated and two new discrete branches/tubes are started. This creates a discontinuity that can be super obvious visually, and problematic for texturing.
I've noticed that in practice, one of the branches always looks like a continuation of the original branch, and the other a smaller offshoot. Rather than starting two entirely new tubes at each branching point, maybe just one tube can be started for the offshoot while the other tube just continues the original tube.
First of all thank you for the great work and especially the extensive documentation! This is super helpful! I just tried your unity implementation of the space colonization algorithm and on my M1 MacBook, it gets very slow very fast to the point of it actually crashing. Apart from the tube rendering (which was expected to be so heavy in performance), it seems that the rebuilding of the KD-tree every frame mainly leads to the crashes (I'd say with a node count of about 10.000). Is this your experience as well? I'm a bit surprised here, because your javascript demos run so smoothly and they seem to be using a KD-tree as well (and not compute shader magic).
In closed venation, multiple branches can converge on one attractor to create closed loops. Each branch will grow until they enter the attractor's kill radius, and if this kill radius is very small it can look like they are connected even though they technically aren't.
To actually get these converging branches to connected together into a single mesh, we need to create a "patch" that connects each branch tip to the others.