Procedurally generated mushrooms caps are defined by generating voxels confined between two equations (see link). The stem is obviously a cylinder.