Jump to content

Terrain erosion


Recommended Posts

Those mountain ridges look quite nice. I guess the circular map format cuts out the valleys at the bottom of the heightmap.

All maps are square internally, so if a rectangular heightmap is given it has to cut off the parts that don't fit. Not a huge problem, I don't think.

Link to comment
Share on other sites

Fine, thanks. I'll start heightmapping the places of the battles of the peloponnesian war (respectively which are described in Thukydides book, since this is my main resource) the next days. I'll try to supply other relevant information to the specific battles as far as I am able to find it. Is there a list of battles that should get implemented?

Link to comment
Share on other sites

By the way, we do support rectangular (non-circular) maps, so if you really want to copy an exact heightmap, it should be possible :) There's a value in the scenario XML for this ("CircularMap").

If rectangular maps exist they must work like the circular maps, by hiding the parts of a square heightmap that fall outside a predefined shape. That probably happens somewhere in the simulation code...

Link to comment
Share on other sites

Weren't rectangular maps decided to be dropped, along with engine support?

Dropped in what way? :) We don't make square maps anymore, so you won't encounter them very often, but as long as there's no difficulty supporting both I don't see why we wouldn't. Actually importing heightmaps is a good reason to allow square maps, for those who want high accuracy to a real-world map. The circular maps might cut off important features as in the above example.

Link to comment
Share on other sites

Well.... A circle is more than just a round shape.

In this way, one could say that circle maps are "bigger." But since in game, we make a square, then trim off the edges, square maps are actually bigger in this case :P

/tangent

Edited by gudo
Link to comment
Share on other sites

While we're on the topic, Unity's Terrain Toolkit has some cool features we could borrow.

I don't see how we could borrow them since it's not open source :P We could get some ideas, implementing them is the challenging part.

If we implement fancy terrain modeling techniques, why not do so in JavaScript and make them part of the random map generator? Unless it turns out to be a very slow process, but slow processes are annoying, we should make them fast. I've seen some decent terrain generators even in old 90s games. The random maps could certainly benefit from more realistic terrains, no less than Atlas.

Link to comment
Share on other sites

I don't see how we could borrow them since it's not open source :P We could get some ideas, implementing them is the challenging part.

If we implement fancy terrain modeling techniques, why not do so in JavaScript and make them part of the random map generator? Unless it turns out to be a very slow process, but slow processes are annoying, we should make them fast. I've seen some decent terrain generators even in old 90s games. The random maps could certainly benefit from more realistic terrains, no less than Atlas.

I agree. Keep in mind though that implementing it for random maps means you would have to generate a random map and save it as a scenario to use a random map ability for non random maps. Is there any part of the code that can be accessed by both (Atlas and rms)?

Link to comment
Share on other sites

SimCity 4 (at least) had a nice erosion script. I'm sure you can find some references online for how they did it. The basic idea is to accentuate small local discrepancies. The problem arises when there is no discrepancy, as you have to create them. To simulate it properly, we'd have to consider the terrain (rock, grass…).

I'm sure we could get a nice result for any map in under 5 seconds of computation, which remains acceptable to me.

Link to comment
Share on other sites

I haven't looked into the code, but there's a few things I'd like to see first. Like custom Javascript brushes, for example. I'm thinking we could have a general system where you can select, for instance, the "biome-alpine" brush and paint it over the terrain, and it changes the terrain textures and objects to match that biome. Such a brush system could also be made to modify the terrain in specific ways, with erosion being one of them.

Let's say we'll simulate erosion as the carrying of dirt by water as it flows downhill. Here's a super-simple way to model it:

  1. Create a temporary texture that is several times larger than the piece of terrain you are eroding (eg 8x) and copy into it the terrain heights, with blurring/filtering to avoid jaggedness from stretching.
  2. In each texel store (at least) two values: the interpolated height, and the amount of water flowing through it over time.
  3. "Rain" water in a Gaussian shape at the middle of the brush. Texels that receive water add it to their water amount.
  4. For each texel A that has water in it, find the lowest-height neighbouring texel B that is of lower height than that A.
  5. Move water from A to B until their (height+water) values are equal, or A runs out of water.
  6. Depending on the amount of water that is moved, move with it a corresponding amount of dirt (lower height of A and add it to B ).
  7. Repeat from 3.
  8. Heightmap values become the average of the texels' heights. Modify textures based on finer data in texture.

This will probably need a separate result texture to do properly, though good news is that all the simulation should be straightforward to do on the GPU.

Edited by myconid
  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Ok, it's been implemented. In Atlas, File > Import heightmap, you select an image file and bam. Code: https://github.com/m...importheightmap

Still pretty basic, though. Always generates a map of the same size, for example, based on the default map, and ignores the parts of the heightmap that are outside those bounds.

Forgive my stupidity, but how can I get this working?

I downloaded these folders, but obviously this is not sufficient^^

Do I need to compile it to get it working?

Link to comment
Share on other sites

Ok, I downloaded the branch "importheightmap" and installed Visual Studio 2010 from MSDNAA. I tried to follow the http://trac.wildfiregames.com/wiki/BuildInstructions , but after opening build/workspaces/vc2010/pyrogenesis.sln. in VS I have a problem with "Make sure to select the "Release" configuration to build an optimised, more playable version of the game (the target will be pyrogenesis.exe)." since I didn't find a "Release" configuration in VS and there is no pyrogenesis.exe anywhere (also not in the branch itself.). If I try to compile anyway, I get an error like this: "0x7d4e237e in pyrogenesis_dbg.exe: 0xC06D007E: Module not found."

I know I'm annoying, but I don't really know something about programming except LaTeX, so sorry.

Link to comment
Share on other sites

I've never built the engine on Windows either, but it sounds like something went wrong when you executed update-workspaces.bat. Since you need to build Atlas to use this feature, you need to resolve the wxWidgets dependency first.

Did you compile or install wxWidgets?

Link to comment
Share on other sites

I've never built the engine on Windows either, but it sounds like something went wrong when you executed update-workspaces.bat. Since you need to build Atlas to use this feature, you need to resolve the wxWidgets dependency first.

Did you compile or install wxWidgets?

That is where I hit a wall it seems that wxWidgets2.8 the recommended version has a VS6 project file that will not upgrade to VS2010 solution file.

Enjoy the Choice :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...