Friday Dev Update: Progress Towards the Cataclysm

12:53 PM Unknown 0 Comments

These last couple of weeks I have been delving deep into code. I want to give you all an update on what I have been working on.


New Terrain Generation Algorithm

The terrain generation algorithm has changed to give me better control over the parameters of what an island will look like. The intended effect is to have islands look very similar as how you are used to, except with the occasional more extreme and interesting island. With testing so far, I have seen a lot more islands with interesting features such as extreme cliffs, inland bodies of water, and large islands that are "split" into a number of smaller islands -- meaning pieces of the island's terrain are separated by water.

Also, each randomization of island content will now be separated (in general). This probably doesn't make a lot of sense right off the bat, so let me explain. An island is generated by a string of random numbers. Currently, a lot of the different potential island content uses the same string of random numbers in order to decide if and where to generate. As an unfortunate side effect of this, if logs on an island were generated before merchants, making a change to the number of logs that could spawn on the island my inadvertently affect if there is a merchant, where he is, or what he sells.

So, what I mean by each randomization will be separated is that the individual components no longer use the same string of numbers. With this, I can change the number of logs and be confident the merchant will stay right where he is. This will help improve world stability in a constantly improving game.

Another very exciting consequence of this is that it allows me to much more easily mine information from a particular island. Say for instance I wanted to make a randomly generated treasure map in the future. The map would need to know where some treasure was. I could write code to find a nearby island, get its generation parameters for buried treasure, and basically ask it if it is there and where it is buried. Since it is separate from all of the other generation, it would able to much more easily tell me that information.


New Island Spread

For the most ambitious of the Salt sailors, there is a slight annoyance. As you sail outwards, islands get more and more sparse until it takes a good while to sail between them. This will change with the new island placement algorithm. Once you get so far past the starting island, there are now both large expanses of ocean and island clusters. With this, you may have to sail a ways to find an island (which makes it beneficial to have a nice boat), but once you find one, you are likely to find more. The image here is a visualization of an island distribution generated by the new system.


Optimization

It makes sense that the game can't spawn the entire world of Salt at once. Every island with every tree, and every over-sized deer. It's too much on a poor little computer. That's why, as is very obvious while sailing, the game generates the islands on the fly as you get near them. This poses some problems. It takes a lot of computing to generate the islands. As the game currently is, you can often notice large lag spikes that causes the game to "stick" for a moment when an island generates. It'll scare you're little Salt character so bad that he'll fling your boat wheel out of pure shock.

There are a number of ways we reduce the lag caused by generating islands, but I have been working on improving it even more in hopes to eventually reach a more flawless experience where you don't even notice that islands are apparating out of thin air.

Currently, every time you enter a new grid location (an entire small island fits inside one of these), the game checks all grids around you for a certain distance and sees if there are any islands there that need to spawn. If so, it spawns the island in its entirety. The speed of the spawn is regulated in a lot of ways depending on the current frame rate, but it still has flaws that cause visible performance reduction.

In the new system that I am working on, the spawn radius is no longer fully grid-based, but instead radius based. This means that a whole batch of islands won't be triggered to spawn at the exact same time. Additionally, I am dividing the spawn sequence into two stages. The terrain is stage one, and everything else on the island is stage two. This allows me to set two different spawn radii. One for just spawning terrain, and one for fully spawning the islands. What this will do is allow for further islands to spawn just their terrain so that you can see its outline on the horizon without as big of a performance hit. 

While I was in there, I also changed some things that would retain some island data even after an island had de-spawned. This will help with creeping memory usage by the game.

All of this required a lot of code changes within the island placement and generation system, but I believe it will be worth the time being spent for a much smoother Salt experience.



The downside of all of this is that new content creation is slowed down during it, which tends to be the most exciting type of update for players. We hope that you will be patient and understanding that this type of "under the hood" work is a necessary part of Salt's development process, and we plan to often alternate between the more boring mechanics work and new content creation. In any case, I'm looking real forward to getting this update finished for you guys. I think it will be a nice improvement to the world.

If you want to see some of the new changes first hand, feel free to switch over to the Steam testing branch and give it a go! We'd love your feedback. You can find instructions on how to access the branch here. Note that all of these discussed changes are not yet on the testing branch, but you can look for it all to be there before too long.



- John Gamble (Lead Developer)

0 comments: