Height to vertex weights, a Blender addon

In a previous article I presented a small script that could create a vertex group or vertex color layer with values representing the slope of faces in a mesh. The script in this article is its companion: it creates a vertex group with values representing the height (sorry no vertex color equivalent yet). I decided to make it a separate addon to keep code maintenance a bit simpler.

version 0.0.2 is now available and gives you the same possibilities as vertex colors instead of vertex weights. If you have installed the script you can find this new functionality under Paint->Height.

Terrain modelling

The script was created with terrain modelling in mind. You might for example want to distribute plants based on the height of a landscape mesh as shown in the (rather crude I admit) image below:

The image was created with a mesh from the ANT landscape generator to which a vertex group was added with the height addon (in weight paint mode, in the 3dview with Weights->Height). The result was this weight map:

Because i wanted the grass particles to be more dense at lower altitudes, I tweaked the weights in the resulting vertex group with a vertex weight edit modifier with the following settings:

The resulting map (shown below) was then used a density map for my particle system:


The scripts replaces the weights in the active vertex group to weights that represent the height or creates a new vertex group is necessary. After installation it is available in the 3dview in weight paint mode under Weights->Height It maps the chosen coordinate (x, y or z-axis) to a weight, which will be 1.0 for the largest value encountered and 0.0 for the smallest. These coordinate values are interpreted in either object (local) space or world (global) space. If the the Absolute checkbox is checked negative coordinates will be treated as positive. The mapping from [minimum,maximum] coordinate to [0,1] weight is normally linear, but may be influenced with the Power property. After mapping any values less dan Low will be set to 0, any values larger dan High will be set to 1

Code availability

All functionality of this add-on plus a lot more is now available as a convenient all-in-one add-on on BlenderMarket. It comes with an extensive PDF manual and your purchase will encourage me to develop new Blender add-ons.

The simple script shown in this article is available from GitHub and has an entry in Blenders upload tracker. There is also a BlenderArtists thread for discussing it.

No comments:

Post a Comment