Realistic Grass Generator

1|.The density and length of the grass are determined by the attribute paint, and the density of the grass is controlled in the form of attribute density in the scatter

 

2|.The grass’ direction is determined by the random normal generated by noise

3|. The curvature of the grass is controlled by the vex code, which basically uses a random axis in the xz plane, and rotates the points other than 0 to the direction of the random axis by a quatarien rotation


vector position[];

for(int a = 0;a < @numpt;a++){
    vector pos = point(0,"P",a);
    append(position,pos);
}

for(int i = 1; i < @numpt; i++){
    vector origin_pos = position[i-1];
    vector n = point(0,"N",i-1);
    float angle = point(0,"angle_ramp",i)*ch("global_angle_mult");
    
    for(int k=i; k < @numpt; k++){
        vector origin_dir = position[k]-origin_pos;
        vector4 a = quaternion(angle,n);
        vector new_dir = qrotate(a,origin_dir);
        vector new_pos = origin_pos + new_dir;
        position[k]= new_pos;
        }
}

for(int c = 0; c < @numpt; c++){
    setpointattrib(0,"P",c,position[c]);
    }

4|. Finally, the skin node converts the generated line into a model with width