# grouped prims on a plane

## Recommended Posts

I am trying to make a procedural meadow with fields within that are 'chunked' off into groups (like the example pic) and the number of fields altered randomly with a seed. Any help or pointers would be appreciated.

My current method creates groups that are too 'stringy' and feel like there is a bit of a simpler way that I am not seeing

##### Share on other sites

Are you looking for something like this:

If so, this is really easy to achieve with Scatter, enumerate those points, and attribute transfer the Index attribute on the grid, attribute promote from point to prim, then primitiveSplit on that attribute

After that, you have a clean set of non overlapping primitives built on the initial grid, and it's trivial to find center points, build roads, fences and whatnot.

• 1

##### Share on other sites

To get overlapping tiles, you could measure and randomly multiply the straight distance to random positions.

Edited by konstantin magnus

##### Share on other sites

For non-overlapping tiles there are interesting examples on shadertoy like this: https://www.shadertoy.com/view/3styzn

Edited by konstantin magnus
• 1

##### Share on other sites

Also see:

Labs Lot Subdivision Sop (labs::lot_subdivision::2.0)

##### Share on other sites
Posted (edited)
```//regular boxes copy
int dim = 50;
int bls[];
int bool;
int pt;
int max_s= 15;
int min_s = 3;
int size;
int area;
int dist;
vector ori_pos;
vector pos;
for(int i;i<dim*dim;i++){
ori_pos= set(i%dim,i/dim);
if(removevalue(bls,i)){
append(bls,i);

continue;
}

dist = 0;
int k = i;
while(1){

if(k%dim== dim-1){

dist ++;
break;
}

if(removevalue(bls,k)){
append(bls,k);
break;
}

dist++;
k++;
}

size = min(dist,floor((max_s-min_s)*rand(i+ch("seed"))+min_s));
area = size *size;
for(int j;j<area;j++){
pos = ori_pos+set(j%size,j/size);
pt = pos.y*dim+pos.x;
append(bls,pt);
setpointattrib(0,"class",pt,i);
setpointattrib(0,"Cd",pt,vector(rand(i)));

}

}```

Edited by Librarian

##### Share on other sites

wow thanks for all the solutions guys massive help!

## Create an account

Register a new account