Showing posts with label terrain. Show all posts
Showing posts with label terrain. Show all posts

Tuesday, May 20, 2014

Two Steps Forward, One Step Back

I went back to working on my other project this week. I've made some good progress. I changed my erosion model and things were looking up, but they weren't quite right. So naturally I continued working and mucked everything up. Things went

From this:


To this:


Okay I'm kidding. The second picture isn't actually fire and brimstone; it's just color coded. The red shows how much sediment is in the water and the green shows how fast the water's flowing. That said, things are still off. The sediment should dissipate smoothly through the ocean and slowly build up coastlines. Instead, it seems to gather in pockets, which leads to strange looking pits everywhere.

There three things, at minimum, that I definitely want working reliably before I use this data to generate actual in-game terrain.

First is natural valleys and coastlines. Otherwise the player will spend all their time on 45° inclines. This is something I've had a lot of trouble with. Some of my recent models have almost produced good coastlines, but not quite. This is because I'm now modeling sedimentation better. I think the results will be really good, if I can improve the current model. They aren't too smooth or too jagged and are really starting to look like actual mountains.

Second is stable rivers that are a least a meter deep. The blocks in-game are a meter wide on each side. My plan is for any surface water less than a meter to result in swampland. However, rivers aren't swampy so they need to be at least a meter deep to avoid this. River sources, on the other hand, tend to be either underground or swampy. Ideally, rivers will begin in swampy areas and transition smoothly to proper rivers.

Third is good mountains. It'd be boring if everything was grassland. There are a few things that go into this. They can't be too steep or too shallow. The amount of vegetation should be lower near the top. There should be some rocky outcrops. I'm really pleased with shapes of the mountains in the recent models. They aren't too smooth.

Those are the minimum that I want before using the algorithm in game, however, there are plenty of other things I want to include eventually.

Temperature and humidity. I would love to model these things. They would be super useful for creating natural biomes. However, I imagine they'd also be really finicky and hard to get right.

Snow and ice. While it would be really easy to simply make things freeze above a certain altitude, it'd be nicer to have a little natural variation. These things would also affect river formation, so it might take a lot of work.

Implied features. One thing I did with the new model was remove a lot of complexity. I decided that instead of trying to get everything to form naturally, I would dumb things down and use the results to generate extra features. For example, beaches should form wherever soil meets the ocean. Deserts would form in areas of low humidity. Waterfalls could be created anywhere rivers go over a steep drop.

That's it for today, folks!





Tuesday, March 4, 2014

Large Scale Terrain Generation


This week I worked on large scale terrain generation. The plan is run an environment simulation for some amount of time to create large scale structures (such as lakes, rivers, and mountains). The actual game will then use the large scale features as a guide for more detailed generation.

I'm using a different algorithm to generate the elevation. Specifically, I'm using the idea described on this page. I like this algorithm a lot because it's very simple and produces good results. Compare a planet created with Perlin noise vs. the spherical landscape algorithm:

Using Perlin noise.
Using spherical landscape.
Perlin noise tends to be more uniform resulting in a planet covered in lakes. While this can be overcome by adding multiple noise layers together, there are a lot more variables that need adjusting to get it looking good. With the spherical landscape algorithm, on the other hand, you need only to adjust the number of iterations. It tends to produce more varied results, which look more like oceans and continents.

Currently, the environment simulation works by iterating on several layers of 'fluid'. I use this term loosely because what I'm doing is not at all physically accurate (and I'm applying it to soil and sand in addition to water). The bottom-most layer is rock. Rock doesn't flow at all, but it can be eroded, which results in sand. Sand resists flow more than water, and soil more than sand, which creates flat-lands and beaches. Rain is simulated by evaporating water from every point and redistributing it equally.

The environment simulation is pretty bare bones at the moment, but it's already producing good results. I'll probably continue working to make it better for a few weeks before using it to generate actual game terrain.

Tuesday, February 18, 2014

Vegetation


Another short post this week. I added some vegetation! Importantly, I can use the same code to create other objects. Although, for the time being, I have to hand write object meshes, so I probably won't add many more until I have a way to import them. I added a minimap. This is just for testing purposes and will eventually be taken out. I also did some more optimization that allowed me to increase the render distance quite a bit.

Tuesday, February 4, 2014

Grounded

I've been making progress on my project! I finally got some basic physics implemented (after three days of debugging), so you can walk around the world now. I also did some optimization; things are running a lot faster now. Sections of the world are now generated on demand, so you can walk around indefinitely. I'm not saving or loading sections yet though. I also added in some variation in the terrain, so now there are patches of snow and snow capped mountain peaks.


This week I'm going to talk about how I'm generating the world.

Tuesday, January 21, 2014

Perlin Hills

This week has been unusually productive. I've been working on terrain generation. Already the results are much better than previous attempts of mine. Thanks to researching the topic, I've finally come to decently understand Perlin noise. For generating and storing pieces of a massive world, I plan to adopt some of the methods used by Minecraft. Specifically, I'll be using a file format similar to the Anvil file format, which Minecraft currently uses.

I've spent some time reconsidering the previous block shape scheme I planned on implementing. For the time being, I've largely given up on finding the 'perfect scheme'. Every system I've considered has drawbacks of some kind, and all would have been a huge headache to implement. So, for now, I'm using a simplified scheme. The shape of a block is simply defined by which of the eight corners are present (256 total block shapes). In the future, I will likely consider more complex schemes, but until I find a better one, I'm just going to move forward with what I have now.

As an optimization, no hidden faces are included when the meshes are generated. This is done simply by checking if two adjacent blocks have matching corners on the touching sides.

Here are the next few things I'm going to be working on:
  • Adding textures to give the world some color.
  • Saving and loading sections of the world dynamically so you can move around.
  • Some simple physics so that you can walk around.