# Point Instancing from MASH
This guideline will focus on how to create Point Instancing from Maya using MASH and the Maya Particle Instancer node.
Depending on the source of data for instancing the workflow slightly varies:
- Creating instances with MASH using Multiverse Compound as source
- Creating instances with MASH using Maya geometry as source
# MASH instances from Compounds
In this example we’re going to point instance our Maneki USD asset using MASH: we will scatter them on a sphere and randomize the variations.
You can use as source for instancing any USD file, this means you can point instance compositions.
First we need the Maneki USD assets, which you can download here (opens new window).
Before creating the MASH network we need to change MASH options via
MASH > Create MASH Network [ ]:
- Set "Hide source object" to OFF (or un-hide the source object in Outliner)
This is very important as we respect visibility when writing and if the source object is always hidden the instances will not be written.
- Change the Geometry Type to "Instancer"
- Name the Network Name to your liking, e.g:
- Apply & Close
Now you must go and set the visibility to "Bounding Boxes" in your instancer node, this will allow you to see the instances of Multiverse Compounds in the viewport:
When using Multiverse Compounds as the source data for MASH instancing, you can only display the Compounds in the viewport as bonding boxes until they are written to USD. This is due to a Maya Viewport API bug which we reported to Autodesk, free to put some pressure to have it fixed:
MayaBug-2068: “Draw callback not called with MPxDrawOverride and Instancers
(repro with rawFootPrint sample)”.
Note that after writing to USD and reading back the data, instances will be drawn correctly.
Now let's MASH up things:
- In the MASH Distribute increment the number of instances to e.g 1000
- In the MASH Distribute make your input mesh equal to some source geometry, like e.g. a sphere.
You should see something like this:
You are now ready to Write your Composition, since because the source data is a Compound.
select the MASH Instancer
Perform a Multiverse Write USD Composition with default settings.
You should be pleased when noticing how small is the disk size of the composition.
Now that the file has been written, it's time to read it back:
- create a new Maya scene
- Multiverse Read
Here you go, 1000 Maneki cats in your viewport!
Now lets swap the static Maneki with the animated one for maximum GIF fun:
- In the instancer node replace the “static” Maneki model with the Animated Maneki, which you can Download here (opens new window)
- Reduce the amount of instances so we can see the animation more clearly
- Then Multiverse Write USD Composition
Remember to turn on the timing range from 0 to 24 frames since we are writing an animation.
To confirm that it’s a Point Instance we can inspect from MEOW: we should see ManekiGang_Instancer is colored in green and below should have a "Prototypes" location which contains the instance sources. If you have this particular kind of hierarchy then we have this asset in full Point Instancing which should be fast to load and render.
# MASH instances from Maya geometry
In this example we’re going to point instance six different mushrooms that are actual Maya geometry: we will use MASH to scatter and randomize the variations of the mushrooms.
Note that you could do the same with six USD mushrooms using the above guideline.
First we need the mushroom assets, as shown in the image below we have six mushrooms that will be used as sources for Point Instancing.
Before creating the MASH network we need to change some MASH Options via
MASH > Create MASH Network [ ]:
- Set "Hide source object" to OFF (or unhide the source objects in Outliner)
- change the Geometry Type to "Instancer"
- set the Network Name to Mushrooms.
Select all mushrooms and press Apply and Close. However the default settings is not what we expected: so we need to change that.
Let’s change the distribution of the points to use mesh and scatter. Increase the number of points to 20 to see what happens.
Create a plane, scale it, select Mushrooms MASH network and then MMB drag to "Input Mesh" to scatter the mushrooms on top of the plane.
So far so good, but we’re missing the randomness of the mushroom’s variations. So let’s add that. Go to Mushrooms tab in MASH attribute editor and add ID modifier.
After we add ID Node we should have variations of mushrooms.
Change a bit of settings in the ID Node to add more variations.
Change number of points to 60 to see more mushrooms from Distribute Node.
Turn off "Ignore Ramps" and play with Ramps to variate the scales and rotations.
At this point we increase the final point to 100.
# Writing Point Instances
Select Mushroom_Instancer and use the Write USD Asset shelf button to write it as an USD asset. We use the write asset because, unlike before, the source data is Maya geometry and not Compounds (if they were, you would have instead written a Composition).
Read back the USD and now we should see that the mushrooms are successfully instanced using Point Instancer in USD.
To confirm that it’s a Point Instance we can inspect from MEOW: we should see Mushroom_Instancer is colored in green and below should have a "Prototypes" location which contains the instance sources. If you have this particular kind of hierarchy then we have this asset in full Point Instancing which should be fast to load and render.
Point instancing is a powerful feature from USD and can be used for many things. Covering rain forests, candy land or even rock galore on volcano, using this simple workflow allows you to improve Maya procedural to the next level.
Point instancing is very efficient: you can point instance many millions of instances, this is because no transform is generated for each instance and everything is nicely "packed".
However point instancing in Maya has also some disadvantages:
Because in order to output many instance you need to first generate the data in MASH, you will hit Maya limitations in generating a large number of nodes, also depending on the geometric complexity of your source geometry.
Once the geometry is written to USD and read back into a single Multiverse Compound, viewport performance will be very good. So this complexity issue is only Maya-related and happens before writing.
MASH has limited tools to customize scattering of points in Maya.
If you need to author very complex point instancing setups we recommend to do this work in Houdini, output the data with Solaris and bring it back to Maya with Multiverse which will be able to read it into Maya without any performance issue.