# HG changeset patch # User Steve Losh # Date 1467206565 0 # Node ID af70a83b2de9a105df9848a6dcf32e1d87b8ca7e # Parent 8d1cd743186096e070b26e32c259fd192360378b# Parent d6bebd8d9778e2f91028284dc7404678abf0b85d Merge. diff -r 8d1cd7431860 -r af70a83b2de9 content/blog/2016/02/midpoint-displacement.html --- a/content/blog/2016/02/midpoint-displacement.html Tue Jun 28 23:39:20 2016 +0000 +++ b/content/blog/2016/02/midpoint-displacement.html Wed Jun 29 13:22:45 2016 +0000 @@ -25,6 +25,12 @@ In this post we'll be looking at Midpoint Displacement. +The full series of posts so far: + +* [Midpoint Displacement](/blog/2016/02/midpoint-displacement/) +* [Recursive Midpoint Displacement](/blog/2016/03/recursive-midpoint-displacement/) +* [Diamond Square](/blog/2016/03/diamond-square/) + [project]: https://www.youtube.com/watch?v=G5u79w4qiAA [Unity]: http://unity3d.com/ diff -r 8d1cd7431860 -r af70a83b2de9 content/blog/2016/03/recursive-midpoint-displacement.html --- a/content/blog/2016/03/recursive-midpoint-displacement.html Tue Jun 28 23:39:20 2016 +0000 +++ b/content/blog/2016/03/recursive-midpoint-displacement.html Wed Jun 29 13:22:45 2016 +0000 @@ -22,6 +22,12 @@ the cleanest way to do it. Before moving on to other algorithms I wanted to clean things up by using a handy library. +The full series of posts so far: + +* [Midpoint Displacement](/blog/2016/02/midpoint-displacement/) +* [Recursive Midpoint Displacement](/blog/2016/03/recursive-midpoint-displacement/) +* [Diamond Square](/blog/2016/03/diamond-square/) + [mpd]: /blog/2016/02/midpoint-displacement/ [TOC] diff -r 8d1cd7431860 -r af70a83b2de9 content/blog/2016/06/diamond-square.html --- a/content/blog/2016/06/diamond-square.html Tue Jun 28 23:39:20 2016 +0000 +++ b/content/blog/2016/06/diamond-square.html Wed Jun 29 13:22:45 2016 +0000 @@ -5,7 +5,7 @@ {% hyde title: "Terrain Generation with Diamond Square" snip: "Improving on Midpoint Displacement." - created: 2016-06-27 13:45:00 + created: 2016-06-27 13:35:00 %} {% block extra_js %} @@ -27,11 +27,11 @@ * [Recursive Midpoint Displacement](/blog/2016/03/recursive-midpoint-displacement/) * [Diamond Square](/blog/2016/03/diamond-square/) -Midpoint Displacement is fairly simple and pretty fast, but it suffers from some -flaws. If you look at the end result you'll probably start to notice "seams" in -the terrain that appear on perfectly square chunks. This happens because when -you're calculating the midpoints of the edges of each square you're only -averaging two sources. +Midpoint Displacement is simple and fast, but it has some flaws. If you look at +the end result you'll probably start to notice "seams" in the terrain that +appear on perfectly square chunks. This happens because when you're calculating +the midpoints of the edges of each square you're only averaging two sources of +information. [Diamond Square][] is an algorithm that works a lot like Midpoint Displacement, but it adds an extra step to ensure that (almost) every point uses *four* @@ -168,8 +168,8 @@ └─┴─┴─┴─┴─┴─┴─┴─┴─┘ └─┴─┴─┴─┴─┴─┴─┴─┴─┘ -First we define how do do a single diamond-shaped region. Once again we'll use -a center point and radius to specify the region inside the heightmap: +Once again we'll use a center point and radius to specify the region inside the +heightmap: :::clojure (defn ds-diamond [heightmap x y radius spread] @@ -235,13 +235,12 @@ ## Iteration -Unfortunately we can't use recursion to iterate for diamond square like we did -for midpoint displacement. We have to interleave the diamond and square steps, +Unfortunately we can't use recursion to iterate for Diamond Square like we did +for Midpoint Displacement. We have to interleave the diamond and square steps, performing each round of squares on the *entire* map before moving on to a round -of diamonds. +of diamonds. If we don't, bad things will happen. -If we don't, bad things will happen. Let's look at an example to see why. -First we perform the initial square step: +Let's look at an example to see why. First we perform the initial square step:
            Column
@@ -460,7 +459,7 @@
 
 
-It looks a lot like the result from midpoint displacement, but without the ugly +It looks a lot like the result from Midpoint Displacement, but without the ugly seams around the square chunks. The code for these blog posts is a bit of a mess because I've been copy/pasting diff -r 8d1cd7431860 -r af70a83b2de9 layout/skeleton/_base.html --- a/layout/skeleton/_base.html Tue Jun 28 23:39:20 2016 +0000 +++ b/layout/skeleton/_base.html Wed Jun 29 13:22:45 2016 +0000 @@ -81,13 +81,11 @@