Jump to content
Sign in to follow this  
konstantin magnus

Mycelium growth

Recommended Posts

A simple mycelium growth simulation that works in 2D and 3D:


It constantly adds points to the outer edge of point clouds (1) and favours doing so towards food (2).

1: Direction away from surrounding points:

float radius = chf('radius');
int pts_max = chi('max_points');

int handle = pcopen(0, 'P', v@P, radius, pts_max);
vector pos_avg = pcfilter(handle, 'P');
vector dir_avg = v@P - pos_avg;

v@N = dir_avg;

2: Weighting probabilities and adding points:

int pt_near = nearpoint(1, v@P);
vector pos_near = point(1, 'P', pt_near);
float prox = distance(v@P, pos_near);

float weight_prox = fit(prox, prox_min, prox_max, 0.0, 1.0);
float weight_rim = fit(length(v@N), rim_min, rim_max, 1.0, 0.0);
float weight = dens * (weight_rim + weight_prox);

if(nrandom('mersenne') > weight){
    vector pos_add = v@P + normalize(v@N) * offset;
    int pt_add = addpoint(0, pos_add);
    addprim(0, 'polyline', i@ptnum, pt_add); 



  • Like 7
  • Thanks 1

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this