## This Week In Veloren 36

Thanks to this week's contributors, @Timo, @AngelOnFira, @Acrimon, @KyoZM, @Songtronix, @stevedagiraffe, @shanehandley, @Pfau, @Qutrin, @Nick12, @Slipped, @Zesterer, @appcrashwin7, @Mckol, @haslersn, @Wuyuwei, and @keller!

This month we're featured front and center of This Month in Rust GameDev! Be sure to check this blog out, there is a lot of other great work being done in the Rust gamedev community :) We're also right on the verge of our 0.4 release, and were working to squash all the bugs we can. Expect a new version this time next week!

Here is a new video highlighting different structures in Veloren.

# Contributor Work

With 0.4 approaching quickly, the core team has been hard at work fixing bugs. One of the primary goals is to fix problems that prevent players from opening the game.

@Songtronix has been continuing work on Airshipper and also fixing Discord Rich Presence and Torvus. @Qutrin worked on giving enemies levels when they spawn and displaying it on their nametags. @shandley has been working on audio tweaks. @Pfau started working on the UI component of a map. There is still a ton of work to go on this front.

We've seen a ton of new contributors come in this week, and start working on great stuff! @Jollyfish is working on a large assortment of weapons, mostly varieties of polearms. @Felixader is working on bringing writing back, as they expand the background lore of elves and dwarves. @Argoplantus has been having lots of discussions that focused around system proposals. @Shimox has worked on creating varients for log mobs.

## Erosion and Rivers by @Sharp

In games or as a sort of core for research purposes, the usual way people do erosion is as follows. Approximate your surface as a height map consisting of a series of points with associated altitudes. In Veloren, we approximate each map chunk as a "point". For each point, figure out the neighboring point most downhill of it, and call that the point's receiver. Repeat this until you have a directed and acyclic forest of nodes pointing to your "boundary". The boundary is comprised of the nodes at the edge of the map that aren't expected to have a downhill, usually the ocean.

This graph models river flow using the core assumption of all of these models: water flows along the shortest path downhill until it hits the ocean. Now, reverse the graph. Starting from points that have no incoming flows, for each point, we compute the approximate average rainfall times of the area of the point. Remember, these points represent a surface, in Veloren's case a chunk. This is your volumetric flux, or some parameter related to it. Volumetric flux is the rate of water coming out of the point per unit time.

As you traverse the reversed graph, you take the sum of all the flux coming into each point, plus the water the point receives naturally, and call that its "drainage". This represents the total amount of water that ends up flowing into each point. We also can take this opportunity to try to calculate a slope from this point to its receiver, which is the approximate slope that the water will flow downhill on.

Now, we take all this information and dump it into an empirical formula called the stream power equation. This is intended to model the shear stress of water flowing over a surface per unit time. It relates drainage, slope, and some magic constants. It tells you the expected change in height per unit time from water flowing over the point. You run this on all your points, and that constitutes an iteration of erosion--water flattening out the slopes it runs over. In general, the higher the flux and the higher the slope, the more pressure is exerted. This is one of the reasons why rivers tend to run down high slope areas and make them flat.

That's the basic version of erosion. But you'll note that there's a problem here: when rivers hit a local depression they stop in this model. A local depression is a point with no other downhill points that aren't on our boundary, for example, a lake. This means that this erosion equation can't get rid of depressions, even though it can introduce them. Furthermore, since we're only running erosion in this model and not other geological processes, the more iterations you run, the lower and flatter your land will become.

So if you run it too many times or at too high a delta t, you will end up with a completely flat and uninteresting landscape. So, the above system is kind of limited. It should be stressed that this model is perfectly fine in some circumstances, and it is used by most games that do erosion, which is already a pretty advanced thing for a game to do.

The system also has a lot of trouble generating interesting terrain by itself. It's better at more realistically shaping previously existing interesting terrain. To fix the "rivers stop at lakes" problem, people either make special maps that always flow downhill by construction. For instance, the most popular blog about this, Red Blob Games, has a map where altitude always increases towards the center. So many games that have erosion and copied this article's approach and have a single mountain on an island. Either that or run one of several algorithms that fill in all depressions on a heightmap before running each iteration. You can see an example of that here

The "fill in depressions" method sort of works, but it has two disadvantages:

- It completely removes lakes from your map. This is why you may notice that when people talk about using this method in games and want lakes, they often just have lakes there from the start.
- It is slow compared to the other steps, the best-known algorithms for drainage filling are O(n^1.5). So this even further limits how many iterations can be run.

So, what do we do? It turns out that we are not exactly the first people to notice these problems. Clever people have been hard at work figuring out how to make this equation scale to large datasets. An algorithm addresses our problems in three ways:

- It adds tectonic uplift, another important component of the erosion model that is missing from the simplified version of the stream power equation. It turns out that if you simulate for long enough, tectonic uplift and erosion cancel each other out to form a steady state. This means that erosion can be run for as many iterations as you like without flattening out the map.
- It comes up with a clever algorithm for lake flow connections. This allows us to avoid figuring out how to fill in all the drains to compute a consistent stream tree. The high-level overview is abstract points by the local depression (i.e. lakes) that they are in, and look for the "lowest" path between each pair of neighboring lakes. Then if we start from the boundary and always choose the lowest available path to a lake that we haven't traversed yet, we'll find a consistent path "downhill" between lakes, that will be connected if the lakes are all flooded. This algorithm is O(n + m log m) (sorta) rather than O(n^1.5), which means that even with tons and tons of lakes it finishes pretty rapidly.
- It does this using an "implicit" algorithm that allows you to choose whatever delta t and erosion level you want without destroying convergence.

This is the algorithm we use.

# Player survey

Last week we put out a survey, and we've had a ton of responses! We've got a lot of valuable insight on many topics. With the sudden server population increase this week, it's interesting to get opinions from people who just found out about the game, as well as people who have been a part of the server for a while.

One of the big goals of the survey was to find more about the Veloren player base. And then on an even deeper level, the previous experiences of players in different games. Veloren is trying to encapsulate dynamics and pillars that can be found in many other games. For most people who look at Veloren, they can draw connections to Cube World and Minecraft. It's interesting to see the number of players that have played these games, which is near 90-100%.

If we contrast this to the similarities that Veloren has to Dwarf Fortress, we don't hear as much about the overlap. There is a much smaller subset of players who have played this before; around 30%. Also, many of the underlying systems that dictate large scale world simulation haven't been incredibly visible just yet. This might be a motivation to bring out those systems that players aren't familiar with. We'll see.

An interesting discovery was the proportion of players that liked player vs environment (PvE) over player vs player (PvP) combat. Because of what people imagine of a game like Veloren, the systems that promote PvE seem more commonplace. These types of systems center around teamwork to kill bosses, or quests to find items. This is also similar to the raid systems of MMO games.

On the other hand, PvP combat is quite low, at only around 30%. We can look at many other games that have similar mechanics to Veloren, and see how their PvP systems have progressed. Whether that be Minecraft hunger games, or duals in Borderlands 2, or player combat in World of Warcraft. All of these games are intrinsically PvE games, but have a PvP mask put on them. We can compare that to games that focus on PvP, such as Counter Strike, League of Legends, or Fortnite. These base PvP games would really struggle to introduce elements of PvE into them as core mechanics. This means more than just jungling in LoL, or killing chickens in CS.

Finally, let's take a look at the theme of magic in Veloren. This came down to quite a close decision between soft and hard magic. Soft magic meaning that it exists in the world, however, it is not well defined. Hard magic means the world is focused around it, and it has tangible limitations. Take a look here for more details.

The decision of how magic is included in Veloren will likely evolve with the design and development process. It's hard to settle on this topic when there is so little content in the game. There is already quite a lot that has been written on the lore of Veloren, but how that plays out once mechanics are introduced is yet to be seen. The vote shows that more players prefer soft magic worlds. This is valuable for us to know, as these questions are very much answered with what the player's "idea" of Veloren is.

Next week, we will look at some more of the results from this survey. Stay tuned!