Mushroom Generator Plugin for Maya (Using Python)

I coded a plugin/shelf tool that allows the user to create mushrooms within a few clicks. It gives the user a convenient method of quickly generating many mushrooms with slight variations including modeling, UV unwrapping, and texturing.

The user will be able to reuse this tool to generate mushrooms in the same file as long as the user names it a unique name. Maya does not handle duplicate names well, except in a few cases where it will increment a counter to the name, hence when creating this plugin, I took caution to naming and revolve most naming around a user entered input with a counter attached.

I implemented a system where the user gets to choose the number of mushrooms, the spread in location, the average height the user wants their mushrooms and the standard deviation of the height distribution. Then the code creates mushrooms with a heights that follow an approximate normal distribution according to the average and standard deviation inputted. I used a similar method for adding bend variation: the user can choose the average bend and standard deviation of the bends. To streamline this process, I decided to create a separate function that would return a list of values following a normal distribution curve with the parameters of mean, standard deviation, and size.

The user also has the option to smooth the mesh and when smooth is checked; the option to save a low poly copy is given too. Saving a low poly copy will duplicate the mesh and store all the low poly versions in a display layer named "LowPoly" and store the smoothed versions in a display layer named "HighPoly". To enable this second checkbox only when the first one is checked, required referring between the two checkbox groups and their onCommand and offCommand.

Checking the checkbox for place substance materials will create a substance node material; user will need to manually load substance plugin if it is not already loaded before using this option.

Default assumes the substance (.sbsar) files are the following:




The custom option lets the user pick any .sbsar file and does not change any parameters the substance file comes with.

For the implementation of the substance node shaders, I made a separate class for the creation of the shader to be able to create instances. Making it more modular makes it easier for reuse in the future.

An example of mushrooms generated without shaders applied:

mushrooms no texture

Renders with the material applied (and manually added lights to scene):

m/mushrooms image 1

m/mushrooms image 2

m/mushrooms image 3

The code uses the revolve command from Maya, and it requires specific settings as follows:

revolve options

Code here: