Devlog #2: Terrain improvements


If you are interested on what I plan to be in the game in the future, or what I worked on last month for my game, please take a look at my previous devlog.

What I’ve been working on so far

I planned to start working on the gameplay (the thing you do while playing the game, other than walking, since walking is not gameplay). However I ended up getting sidetracked by more important matters, such as bug fixes, and improving the terrain system. Let me explain, in detail, what I’ve been working on.

  • A saving and loading system. It allows multiple “subsaves” inside of each save. A subsave could be, for example, an autosave, or a manual save, and the subsaves are contained inside a larger save file, which means your save files and autosave files aren’t thrown into a messy list with the subsave files of another save, keeping all your saves independent from each other, and reducing player confusion.
  • Improved the terrain system. The changed I’ve made to the terrain system are so massive, it warrants its own section to properly explain it all.
  • A technology system. The only gameplay-related thing I managed to get around to adding. The tech system allows you to build and repair tech using resources that you can find and make.
  • Added jetpack functionality, allowing you to fly. Using the jetpack after a jump will give you an extra boost of vertical speed. The jetpack also has unlimited use time in space, allowing you to fly around your ship and make vital repairs. Expect interesting gameplay in the future with this feature.
  • Weapons now have a thumbnail generated, based on its appearance or any upgrades it has.

Terrain Difficulties

Teaching terrain basic math if more difficult than you’d think. Part of the reasoning is because dirt can’t think. But the other part is that terrain in games is very difficult to get right.

When I created the first iteration of the terrain system, I didn’t have much time and wanted to get something to show off. So I used a method to make terrain that wasn’t very flexible. The new terrain is much more flexible. It allows more variable heights based on biomes, uses a chunk-based system, and more impressive mountain ranges.

However this had a side effect. At the edges of every chunk, you could see a weird seam, a line that was lighter than the rest of the terrain. It took me a week to learn what caused this issue, and it was when I wasn’t even looking for it.

Texture

The old terrain system’s height based rock texture was fine for early testing, but it looks terrible, so I decided to fix it. It is now based on the steepness of the terrain. This makes the terrain much more varied in appearance, breaking up the endless grass texture.

Before:

After:

Normals

However, this terrain system had a problem. A big problem. Near the edges, it looked really bad.

I used the normals (normals are used by game engines for the correct shading of 3D objects) of the terrain to find how steep each section is, and the normals were made independently of other terrain chunks using the default normal generator in the engine. To fix this, I made each normal manually instead of using the default engine code.

Before:

After:

Looks so much better now. And it fixed the issue with the light border around the edges of terrain.

Optimization

Of course, optimizing the terrain to have good performance wasn’t easy. It helps that I have a low-end PC to test how the game would play on weaker hardware. With integrated graphics I get a stable 40 FPS with all the graphics settings set to medium-low values.

I had to make chunk generation multi-threaded, or every time it generated a chunk, there would be a large frame drop. Of course, that wasn’t enough, as I still had frame drops when moving fast in the starship. So I had to make the terrain render at a lower quality when moving very fast.

… And that’s it!

Phew, that was a lot of explaining. The next thing I will hopefully get to working on is more gameplay stuff. Lootable structures, more items, weapon customization, and maybe even make a start on adding npcs. Please leave your feedback and ideas in the comments below, and if you enjoyed this post, join the Discord!

Get Endangered Space

Leave a comment

Log in with itch.io to leave a comment.