# Procedural rock algorithm

I'm looking to create some procedural low poly rocks and boulders for a game.

I haven't found much interesting information on the internet other than 3D software articles. Not sure what way to go.

• Like @jackmott suggested you could use a sphere. But I would also suggest using a randomized height map on the sphere. You could create a "sample" rock height map and then randomize from there. – Andrew Wilson Jan 29 '16 at 6:15
• You definitely should check a brilliant website by procedural genius Inigo Quilez: iquilezles.org. Also see his shadertoy.com. – Qbic Feb 11 '16 at 14:34
• Philip Rideout's par_shapes.h single-file library for parametric meshes has a rock generation algorithm based on simplex noise. You may be able to derive some inspiration from the implementation. – Lars Viklund Feb 11 '16 at 15:49

## 2 Answers

One approach could be to start with a sphere, perhaps pick some random parameters to stretch it varying amounts so some rocks are roughly round, while others are roughly egg shaped, then use 3D perlin or simplex noise and it's fractal variants (see the fbm methods in the link) to push vertices in towards the center, or pull them out, by some multiple of the perlin noise result. You would just pass the 3d coordinate of each vertex to the 3d perlin noise function, get back a float in the range [0,1], and use that to push or pull the vertex.

If you let me know what environment/language you are working with I can go into more detail.

• I'm using C++ and Direct3D. I started out trying to modify a point cloud convex hull but the results are not very good. I'm going to try what has been suggested here and start from a sphere. – dotminic Jan 29 '16 at 16:33
• I've got some handy perlin noise code in c++ here: github.com/jackmott/FastNoise-SIMD though if the spheres are low poly enough it might make more sense just to do some random displacements of verticies. Using noise would be overkill. – jackmott Jan 29 '16 at 16:37

When I create rocks in modelling softwares, I start from an icosaeder, fhen stretch it around, scale it a nit, then I just pick random vertices and I pull them a bit out. I suppose, the same can be made with code