Jump to content
  • Advertisement
  • entries
    444
  • comments
    1237
  • views
    774625

Stone

Sign in to follow this  
JTippetts

1520 views

Just can't seem to keep with a top down perspective. In the end, it's just too limited a perspective for my tastes.

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.
Sign in to follow this  


5 Comments


Recommended Comments

Thanks guys. I'm really wanting to stop just tinkering around, and try to devote the time to finally finish an isometric game. Hopefully work and Real Life will cooperate.

Share this comment


Link to comment
Your result looks very good. About the algorithm, it would be nice to see keywords like "erode", "dilate" or "distance field" in your post :) Do you know such terms?

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!