Been playing around lately with stonework: pavings, walls, etc... for isometric. Stonework is one of those things that can be tricky to get right, but boring to play with. But it can sure pay off if you get it right.
Today, I've been fiddling around with doing stonework via Displacement modifiers in Blender. A Displacement modifier, of course, displaces geometry based on a specified displacement texture. It works best on very highly detailed surfaces, so a subdivision is required, either via manually subdividing the mesh to a deep level (not really recommended) or applying a Subsurf modifier in the stack before the Displacement modifier.
However, as neat as displacement mapping is, it's nothing without good displacement maps to work with, so to that end I spent some time this morning revisiting some of my old code for generating stone floors that I posted about a long time ago. That old stuff dealt with taking a region of Voronoi cells, finding the edges between cells, and blurring the edge pattern to form the stones of the pattern. I have modified my pattern a little bit, and have been able to achieve some fairly nice results.
The process begins in the same way as before, with a map of regions, each region representing the location of a stone. The regions can be a Voronoi diagram, a hand-made map, any sort of tesselation, really. Each region is a different shade of grey in the map, to differentiate edges. Here is a sample pattern:
Just a bunch of grey areas.
The first step is to process the region map for edges. This is a simple matter of iterating the map and at each pixel, testing to see if it has at least one neighbor that has a different pixel value. In the edgemap, these edges are set black, everything else is set white. Here is the result of this step:
Once I have the edge map, I then send it to a Gaussian blur routine for a few iterations to smooth out and round out the lines. However, this has the effect of lightening the darks, so to speak, and losing contrast, so after I have blurred it several times, I pass it through a threshold filter that sets any pixel below a certain threshold to 0 and any pixel above it to 1 to restore contrast:
This thickens the lines, rounds the corners, and makes the regions a little more natural-seeming. Of course, the various parameters such as strength of blur, number of blur iterations, and threshold cutoff value are specifiable.
Once I have the rounded edge map, I apply another processing step, similar to the edge-processing filter, to give the regions shape. Formerly, I would perform this step as a byproduct of the blur stage that rounds the corners, and just use the blurred regions for the stones shape. However, that method doesn't work as well as I would like. Instead, I iterate the map some arbitrary number of times, searching for edges as before, and setting edges of a gradually increasing value. In effect, I shrink the regions by 1 pixel each iteration, and increasing the value of the edge pixels by a small increment each step. Here is the rounded edge map after an application of 32 iterations of this process:
This process does generate many artifacts that must be subsequently smoothed by another pass or two of Gaussian blur. After the blur pass is accomplished, I am left with fairly smooth, rounded regions. At this point, I will remap the values in the map to tighten up the corners, smooth out the tops of the stones, etc... For simplicity, I have just been remapping via a bias function. Here is the result of applying a bias of 0.9:
Now I have the rough shape of the stones, all they need is a little bit of surface roughness. I generate a buffer full of fBm noise, scale it to some range, and subtract it from the final heightmap. The final result of all this looks like:
Now I can import this greyscale map into Blender as a texture, apply it as the texture modifier for the Displacement mapping, apply a colormap, and tweak everything until I get something I like:
I'm pretty happy with that, for as relatively little time as I spent on it. Certainly better than my attempts at painstakingly building such a scene one modeled stone at a time.