Why I now worship Perlin Noise, the God of Infinite Creation

So, I’ve been AWOL since…May? Which is obviously a record and of course I’m having a plaque made. That aside, I actually had quite a few (like 2) posts half-written, the biggest of which was supposed to be all about this semester being a boss battle with the Specter of Personal Responsibility and his 4 ghoulish heads of despair – “Senior Research Project”, “Career Hunting”, “Web Dev”, and I forget the fourth one. Oh and the Specter’s malignant skin tag of “Fixing my PC” is probably on there somewhere. Ironically(?), the Specter got me before I could finish the post and that is a crying shame because it was beautiful and now you’ll never get to see it.

Oh well, life goes on.

Completely ignoring that “life goes on” thing to talk about what happened in the last 6 months

Real quick, then we’ll get to the stuff I actually want to talk about: So Many Levels is my first project to ever become a zombie. After TooManyGames, I finally got to put it down and think about other things (like PUBG, and the Magic Mirror my girlfriend and I keep forgetting to build). I thought that would be the end of it, but it Just. Won’t. Die. I picked it up again at beginning of the semester so we could submit it for MAGFest, but I’m not sure if I’m supposed to talk about how that went, so I’ll keep it hush-hush for now. I’ve put it down again since, but my professor is working on a procedurally generated “Infinite” mode for it. That’s pretty much it, so speaking of procedurally generated:

Apparently disappearing for half a year destroyed my ability to segue.

For the past week I’ve been hiding just slightly out of the Specter’s line of sight, so naturally I’ve been doing what anybody does to relax, namely playing God. A couple weeks ago I finally picked up Python because, as much as I love Lua, she doesn’t see nearly as much use in the real world (according to the Internet). While messing around with it, I discovered that I could draw colorful boxes to the terminal. Naturally, my first thought was “Yeah this is nice and all but what if it was a planet?”

Obviously a planet. Definitely not a lava lamp.

I dunno, I guess Dwarf Fortress was hanging out in the back of my head. It usually is.

An explanation of what’s going on that’s so simple, it’s not worth correcting me about if you actually understand the concepts

The way this kind of thing works is a picture of “noise” (random gray pixels) is generated using math (just go with it), and the brightness of those pixels determine whether or not a cell on the map is green (land), or blue (window cleaner). The specific kind of noise used here is called Perlin Noise. It was invented by a guy in the 80’s while he was working on TRON, and I think it might actually be God in math form.

You see, you start your code with the continents. That’s fine and all, kind of cool, not too impressive. Then, you get more detailed. Layering the noise with itself creates sharp, complex edges along the landmasses. There are different elevations now; suddenly there are sandy beaches, and snow-capped mountains. Then, you start moving forward in time (the noise is 3D, so time is the third dimension in this case). Continents rise high into the air and sink beneath the sea. You’re a passenger in a satellite watching the history of the planet unfurl in front of you. It’s kind of mesmerizing, but it’s still missing life.

So, to start, how do you add trees with realistic, varying distances  between them? Much like the brakes in my car, you can keep making the same weird noise! If, instead of elevation, you use the noise to represent the odds of a tree being born, the world becomes populated with forests! Add another layer of noise to represent rainfall and now you have deserts!

All that doesn’t even touch on some other uses for it. With some tweaking, it can simulate fire, or lightning, or clouds, or waves. Here’s a gif of it simulating the sun’s surface.  And even though it can generate basically every natural phenomenon (at least the ones I can think of without trying particularly hard), the math behind it is really simple…

Pictured: Really Simple Math

…relatively! It’s hard to explain, I’m just kind of flabbergasted by the whole thing, which is why it’s pretty much eaten up my whole week (and my soul). The Noise is in everything. The Noise is everything. All glory to the Noise.

What I’m Gonna Do About It

Well… I’m gonna write about it. I’ve been experimenting with this since Monday and I feel like I’ve just scratched the surface. So, for the next few months (maybe) or weeks (probably), I’m going to keep iterating. In my writing, I’ll try to get a bit more in-depth about the process than I usually do, so hopefully it can be as fascinating for you as it is for me. I already have much more to say about this than I ever did for So Many Levels.

As of yet, I don’t know if a game is gonna come out of this or anything, but maybe it’ll be cool just to see how detailed and realistic I can get my planet.

One thought on “Why I now worship Perlin Noise, the God of Infinite Creation

Add yours

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A WordPress.com Website.

Up ↑

%d bloggers like this: