From BlenderWiki

Jump to: navigation, search

Rock Generator


The Rock Generator script for Blender 2.5 was launched on seeing a need for a way to quickly produce finished rock objects inside of Blender. This require that the add-on use a few input parameters to generate a base mesh, apply modifiers for detail, create and modify textures for displacement mapping, and be able to create and modify materials and procedural textures for the materials. In addition, to better reflect nature the generator required an element of randomness be built in to each aspect of the generator.

The base methodology of the add-on is based on Andrew “BlenderGuru” Price’s asteroid tutorial. Additionally, aspects of Sascha Henrichs tutorial for creating a rock with procedural textures in 3ds Max were integrated.

Rock Generator
Add rocks
UI location Group: AddMesh
Version 1.3 Author(s) Paul Marshall (brikbot)
Blender 2.59 v40249 License GPL

Executable information
File name add_mesh_rocks
Current version download -> snapshot
Python modules NumPy Recommended




  • Download an appropriate NumPy build
  • Place "numpy" folder in Blender's module folder
    • Ex: \\.blender\2.58\python\modules
    • Ex: C:\Program Files\Blender Foundation\Blender\2.58\python\modules

Rock Generator

  • Download script
  • Place in Blender's scripts folder
  • Enable add-on from Blender's add-on menu


The add-on panel has been divided into five main sections. The first only contains the control for the number of rocks to generate. The second modifies the XYZ size controls. Third are the shape and modifier controls. The fourth box contains the material and texture controls. Finally, the fifth box is for controlling the random seed.

Size Controls

The size controls consist of a trio of controls for the X, Y, and Z dimensioning. The first two controls control the boundaries of the generated rocks with the top controlling the lower bound and the lower controlling the upper bound. These bounds are not hard bounds: it is possible to have rocks generated that fall outside these bounds. They simply define where most rocks will fall. If the two are the same, no randomness will be used on that axis when generating the rocks.

The mean value for the rocks is controlled the third control labeled skew. Adjusting this value up and down moves the mean proportionally between the upper and lower bounds of the distribution. The possible range of skew values is -1 to 1. When the skew is set to -1, the mean value of the distribution will be the lower bound and when the skew is set to 1, the mean falls instead on the upper bound. Setting the skew to zero results in a normal distribution. Internally, the skew is acting like a percentage. However, mathematically you can’t have -100% to 100%, so the add-on takes the raw skew value, divides it by two, then shifts is up by 50%. This means that internally the add-on sees -1 as 0% and 1 as 100%, with zero being seen as 50%.

The final control is a check box to scale the displacement textures. This is an option because it changes the way the mesh is built which changes how the displacement textures look. If left unchecked, the displacement textures will not be scaled. This will not be a problem the size of the rocks are not on an extreme (between 1 and 2). For really small rocks the displacement texture may be much too large or with really large rock the displacement texture may be much too small. In such cases it is advisable to use scaled displacement textures. However, the textures are scaled independently in the X, Y, and Z directions so the resulting textures may not be desirable if one of the dimensions is very different from the others. In such cases it is advisable to use scaled displacement textures. However, the textures are scaled independently in the X, Y, and Z directions so the resulting textures may not be desirable if one of the dimensions is very different from the others. To help with this, as of version 1.2, it is possible to manually set the scaling factor for the X, Y, and Z directions individually. Additionally, it is possible to use the scaling to distort the textures to create other effects such as the wind-blown sandstone look (see Sandstone preset for example).

Modifier Controls

These controls control the various modifiers that are applied to the rocks. The modifier stack that is generated consists of two subsurf modifiers, four displacement modifiers, and an option smooth modifier. There are six sliders for controlling the modifiers, with two controls for each type of modifier. The top two modifiers control the deform modifiers, the middle two control the subsurf modifiers, and the bottom two control the smooth modifier.

The deformation slider controls the first two displacement modifiers. These two modifiers focus on the base shape of the rock. This slider is in actuality the mean value for a Gaussian distribution, with the variance of the distribution linearly related to the mean such that the higher the deformation, the greater the variance. The second of the two top sliders if the roughness slider. Here, roughness controls the last two displacement modifiers for the smaller details of the rock. As with the deformation slider, the roughness control is also acting as the mean value of a Gaussian distribution with the variance generated from the same roughness value.

The two subsurf modifiers are identical and are both controlled from the middle two controls. The upper of the two controls is the render detail level. This links to the render slider found under subdivisions in the modifiers. Below the detail slider is the display detail control which controls the display detail shown in the 3D viewport. This directly links to the view slider under subdivisions in the modifiers. These two settings do not have any randomness involved.

The final two sliders control the optional smooth modifier. When the sliders are both set to zero, the smooth modifier is disabled and not added to the modifier stack. If both sliders are greater than zero, a smooth modifier is added. Likewise if both are set back to zero, the smooth modifier will be removed. The smooth factor control provides a mean value for a Gaussian random number generator and the variance is linearly related factor value such that a greater factor value results in higher variance. The generated random number sets the factor value of the smooth modifier. The smooth iterations control is directly linked to the smooth modifier’s iterations slider.

Material Controls

The rock generator add-on provides the option to generate materials and textures for the generated rocks. By default, this is not enabled. When material generation is enabled, the user is presented with the ability to adjust the base RGB values, the brightness of the materials, the roughness of the materials, how shiny the materials appear, how hard the materials appear, and the apparent mossiness of the rock.

The color control is composed of three sliders representing RGB values: the first slider controls red, the second controls green, and the last controls blue. Each component is linked independently to a Gaussian distribution with the input values serving as the mean. As the RGB values approach zero, the variance also approaches zero because smaller differences between the different shades become more noticeable at very small values.

Brightness and roughness both control the diffuse shader for the materials. Brightness serves as a mean value for a Gaussian distribution, and provides a basis for the variance of the distribution. Because of this linking the variance approaches zero as the brightness nears zero. Brightness does not affect the shade of the color, only the brightness of the shader. Roughness acts the same way, except it is first lineally scaled first. The control provided has a range of zero to five, but the actual resulting range is scaled from zero to π. Roughness also controls the normal values for the textures. Here, roughness is not scaled, though it still provides a mean and variance for a Gaussian distribution.

Shine and hardness both correlate to the specular shader, with shine providing the mean and variance for a Gaussian distribution for the specular intensity. The hardness likewise provides the mean and variance for a Gaussian distribution, but this instead maps to the hardness values of the shader.

The add-on has a basic, texture based implementation for moss. The two moss textures are always generated, and the color influence can be controlled with the mossiness slider. A value of zero disables the textures completely and the max value of one will cause the two textures to have a strong color influence.

Random Seed Controls

Because the script extensively uses random number generation, it must be seeded. The first option, which is also the default, is to use a “random” seed. In actuality, the seed is not really random but is based on time. Because of this, it will always result in a unique seed. The alternate is to specify a seed for the generator. This will result in a predictable sequence of outputs.


The rock generator add-on has support for preset values. To load a preset, simply select it from the drop-down list. The specified preset values will then be loaded.

The presets are stored in an XML file called “add_mesh_rocks.xml” which is located in the same directory as the add-on. You may add or edit preset values in the XML file, but you must follow the format exactly or the add-on will crash. If you have irrevocably modified “add_mesh_rocks.xml”, simply delete the file and on the next run the add-on will attempt to create a new XML file with the original settings. Two things to note: all your customizations to the original will be lost, and if you are working on Windows and Blender is located in Program Files then you will need to run Blender as an administrator the following run to give Blender permission to create the file. Do not attempt to modify any other file: if you do so it is at your own risk.

The preset values specified are as follows:

  • Default: this is the clean slate that the add-on initializes to.
  • Asteroid: creates larger asteroid-looking rocks
  • River Rock: generates rocks similar to the classic river pebble often used in landscaping.
  • Sandstone: this setting generates rocks that have a very smooth, horizontally worn appearance.


Up to Extensions:2.5/Py/Scripts