Giter VIP home page Giter VIP logo

unity-space-colonization's Introduction

Requirements

Interface guide

Screenshot of Unity with the custom space colonization interface shown.

Algorithm parameters

  1. Attraction distance - branches that are within this distance (and outside the kill distance) of an attractor will grow towards that attractor.
  2. Kill distance - how close branches can grow to attraction nodes before stopping.
  3. 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

  1. Material - reference to a material object that is applied to each individual branch segment.
  2. 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

  1. 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.
  2. Attractor gizmo radius - size of the editor gizmos that indicate the position of each attractor.
  3. 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)

  1. 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

  1. 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

  1. 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

  1. Iterations to run - number of times to run the simulation. Start small until you know what you're doing!
  2. Run - press to run the simulation for the number of times chosen above.
  3. Reset - press to remove any previously-generated branches so growth can start over.

Export

  1. Filename - name of the file you want to export. Be sure to provide a file extension.
  2. Export - press to export the generated branches on the screen to a file with the name provided above.

unity-space-colonization's People

Contributors

jasonwebb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

unity-space-colonization's Issues

Implement custom Inspector UI

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.

Make main branches more continuous

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.

Implementing bounding shapes

  • Abstract bounds check to new method
  • Integrate bounds checking into attractor generation
  • Integrate bounds checking into update loop (but make toggleable for performance?)
  • Figure out how to automatically assign provided bounding mesh to the Bounds layer (on Inspector change event?)

Implement obstacles

  • Abstract obstacles check to new method
  • Integrate obstacle checking into attractor generation
  • Integrate obstacle checking into update loop (but make toggleable for performance?)
  • Figure out how to automatically assign provided obstacle meshes to the Obstacles layer (on Inspector change event?)

Average performance

Hi,

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).

All the best,
Moritz

Implement closed venation

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.