Alright, time for another script that I wrote recently to help me during some productions. It’s for distributing objects across a surface and yes, I am aware of the fact that there are already some (and quite useful) scripts available. But everything I tried didn’t give the expected results, no matter how the process worked. There are either scripts that emit particles based on textures, some that let the user paint objects on the surface and some that use some other random placement configuration. But the result is usually rather spotty, meaning that the distribution of objects shows either large gaps or the objects are very closely placed right next to each other. This might work in certain situations but I needed something more evenly spread out since I needed to create a large grass plane (without any use of hair or anything) and also trees, bushes and things like that.
So I came up with the idea of using the grid structure of the scatter surface to generate the objects, using the positions of the vertices. With an optional offset of the vertices the resulting placement is not visible as being based on a grid and still the copies will be evenly spread out without any particular gaps or clusters.
The script itself is pretty straight forward. The user can only do what he’s supposed to do and this should lead to less errors. All modifications are being made on a copy of the original surface leaving it untouched in the background.
Just copy the script to any script directory that is accessed via maya. Run the script by executing “icPolyScatter” (without quotes) in the script editor. You may as well build a shelf button for easy access.
- Scatter Name: You must define a scatter name in order to access the functions. This name is added to all generated nodes and helps any naming problems.
- Vertices: The vertex count of the (reduced) scatter surface. Surfaces up to 1000 vertices should still perform fine. The higher the count the slower the script will execute it’s functions.
- Reduce %: The amount of poly reduction that is applied to the surface to reduce the density of vertices and to help with the distribution. Use the ‘Edit‘ button to adjust the poly reduce node.
- Max Face Area: Displays the maximum face area that will not be subdivided. This value is based on the average area of every 5th face. Higher values lead to less faces being subdivided when using the subdivision option.
- Random Offset: Defines the maximum offset for a vertex when displaced. The calculated value is a 3rd of the average edge length. This helps to beak up any regularity of dense scatterings.
- Subdivide: Subdivides any face which area is above the given ‘Max Face Area‘ value.
When applying the displacement any vertices that are generated by either the subdivision option or the poly reduction process will be conformed to match the height of the underlying original surface. This should prevent any positional offsets which can make the instances float above or below the surface.
- Position Offset: Offsets the instances to above or below the surface. This is only an offset and not an absolute value. The value can be interactively adjusted once the scattering is completed.
- Rotation Offset: The maximum amount in both directions that each instance gets rotated along the y axis. The value can be interactively adjusted once the scattering is completed. The attribute is not available after scattering when using the ‘Align To Surface Option‘, as the alignment is only calculated during the initial scattering. If another value is needed the scattering must first be undone.
- Tilt Offset: The maximum amount in both directions that each instance gets tilted along the x axis. The value can be interactively adjusted once the scattering is completed. The attribute is not available after scattering when using the ‘Align To Surface Option‘, as the alignment is only calculated during the initial scattering. If another value is needed the scattering must first be undone.
- Scale Offset: The maximum uniform scale amount that modifies the original scale of the scatter object. The value can be interactively adjusted once the scattering is completed.
- Min Distance: The minimum distance the instances should be apart from another. This is an additional function to help with any clustering of instances.
- Dropout %: Generates holes in the scatter. The higher the value the higher the chance that a vertex is skipped.
- Include Small Area Vertices: On: The dropout percentage is calculated from all vertices, including the vertices from small faces. This results in a little sparser scattering. Works only with the reduction feature.
- Assign IDs: Set to the amount of different objects to instance. Automatically assigns IDs to the instancer to randomly assign different scatter objects. The value can be interactively adjusted once the scattering is completed.
- Align To Surface: Rotates each instance to make it perpendicular to the surface.