Terrain Generation with Midpoint Displacement(stevelosh.com)
stevelosh.com
Terrain Generation with Midpoint Displacement
http://stevelosh.com/blog/2016/02/midpoint-displacement/
8 comments
I had a similar experience writing a terrain engine using the quake gl mini-drivers. That was a fun summer! I never managed to make an actual game out of it though...
It seems like these days at least a noise function like perlin or simplex are far better. I doubt I would have understood those at the time though.
It seems like these days at least a noise function like perlin or simplex are far better. I doubt I would have understood those at the time though.
(defn safe-average [a b c d]
(let [total 0 count 0]
(when a (add! total a) (inc! count))
(when b (add! total b) (inc! count))
(when c (add! total c) (inc! count))
(when d (add! total d) (inc! count))
(/ total count)))
Doesn't appear so safe against division by zero!The demo and step by step blog is great but there is some really bad code in it... Is it idiomatic Wisp to keep the surface-level syntax of Clojure but none of the important bits like immutability and abstractions?
So is this a variant of this
https://en.wikipedia.org/wiki/Diamond-square_algorithm
Or is this exactly this algorithm?
> The diamond step. For each square in the array, set the midpoint of that square to be the average of the four corner points plus a random value.
> The square step. For each diamond in the array, set the midpoint of that diamond to be the average of the four corner points plus a random value.
Seems pretty straightforward. If you couple this with a deterministic random function, you could generate a terrain which always is the same, so that would make multiplayer possible.
That's obviously what you would want in game which is very large, without having a game which is too large to download.
https://en.wikipedia.org/wiki/Diamond-square_algorithm
Or is this exactly this algorithm?
> The diamond step. For each square in the array, set the midpoint of that square to be the average of the four corner points plus a random value.
> The square step. For each diamond in the array, set the midpoint of that diamond to be the average of the four corner points plus a random value.
Seems pretty straightforward. If you couple this with a deterministic random function, you could generate a terrain which always is the same, so that would make multiplayer possible.
That's obviously what you would want in game which is very large, without having a game which is too large to download.
Live demos were definitely helpful. Nicely done tutorial!
$ man triangle
NAME
triangle - random mountains using iterative subdivision of triangles.
[…] $ /usr/lib/xscreensaver/triangleIf this stuff interests you there is a nice book called the fractal geometry of nature that has some interesting techniques.
http://www.amazon.com/Science-Fractal-Images-Heinz-Otto-Peit...
http://www.amazon.com/Science-Fractal-Images-Heinz-Otto-Peit...
Thanks for sharing, this is very nicely documented.
Funny fact: it can be used as Grass Generator
Exponent: 7 Starting Spread: 35.3 Spread Reduction Constant: 20.5
Funny fact: it can be used as Grass Generator
Exponent: 7 Starting Spread: 35.3 Spread Reduction Constant: 20.5
This reminds me, does wisp work on Windows yet?
Much later, I got it working, but I was disappointed with the visible seams it tends to lead to. After some trial and error, I came up with an algorithm I liked better for the game I was trying to write at the time.
I thought it was cool enough that I wrote a little tutorial. It's the very first piece of writing I ever put on the web, I think. It's still online (though, alas, I lost my old robot-frog.com domain ages ago):
http://stuffwithstuff.com/robot-frog/3d/hills/index.html