Mapgeneration

Laurimann

New Member
Contributor
World
I want to comment on the climate thing: like you said in that gDoc, doing the calculations of the temperature & humidity maps from the final map might just be an overkill. I also think that after Java receives the raw heightmap from PlaTec, all other maps should be calculated from it and then (the heat and moisture maps are) just (linearly) interpolated - no one will notice the difference apart from decreased execution time.

Also, i got an idea for "fast" way to calculate the global heatmap:
Code:
for (int y = 0; y < map.height; ++y)
    for (int x = 0; x < map.width; ++x) {
        double height_sum = map[y * map.height + x];
        int di = y < map.height / 2 ? -1 : 1;
        for (int i = map.height / 2; i != y; i += di)
            height_sum += map[i * map.height + x];
        heatmap[y * map.height + x] = 1.0 / height_sum;
    }
On a flat map this would result a hot belt on equator and cold at the "poles". A mountain will block the progress of heat towards the "poles" just like it does now. Finishing touch would be to run an aggressive gaussian blur on the heatmap.

With one simple optimization this method would require just width*height operations per coordinate to get the raw heatmap and after that the blur would require something like blur_width*blur_height*width*height operations to finish it off. For a 512*512 map and 4*4 blur this would mean 512*512+4*4*512*512=4456448 operations i.e. roughly 2 milliseconds (of which 94% comes from the blur). However, i haven't tested the idea in practice so i can't guarantee good results.

Edit: Even better, take the average of the heatmap generated above (withOUT blur) and a heatmap where
Code:
for every point on heightmap
    heatmap[x, y] = 1.0 / heightmap[x, y]
The combination would result in a heatmap where elevated areas are colder even at the equator in less than 0.5 milliseconds. :) Then, just move the sun away from the equator 0+30*cos(day/365) degrees and recalculate the heat distribution on the fly for every single day!
 

Laurimann

New Member
Contributor
World
The heigthmap is currently 512x512 px which are only 8192 blocks or meters on each side.
I mean we could just scale this map until it fits our demands and then add noises and stuff to make the medium and small scale features.
Any opinions from some compter science guys about performance and possibilities?
I've been thinking that approach for a long time. Multiply the map edges by four or eight and fill in the gaps with a diamond-square algorithm. Never got it implemented, because my diamond-square is too hardcoded to generate maps with very little or no initial reference (height) points. Performance-wise it's a blink of an eye; possibilities - well, it'll just make the map bigger, as if zooming into it.

Additionally i've been thinking about generalizing the PlaTec output from squares to arbitrary rectangles and later, if there's need for it, turn it into a "pole form" so that the end result could be wrapped on a sphere just as you can wrap a paper map of Earth onto a sphere now - it's not seamless, but it gets the job done, and poles can be generated using the PlaTec produced heightmap's north and south edges as seed(s).
 

Nym Traveel

Active Member
Contributor
Art
World
With one simple optimization this method would require just width*height operations per coordinate to get the raw heatmap and after that the blur would require something like blur_width*blur_height*width*height operations to finish it off. For a 512*512 map and 4*4 blur this would mean 512*512+4*4*512*512=4456448 operations i.e. roughly 2 milliseconds (of which 94% comes from the blur). However, i haven't tested the idea in practice so i can't guarantee good results.
You might wanna look at the climateSim repo I have on github.
I have it implemented this way at first, with some additional features.
Also there's something that takes the current heigth into account.
If I read this right at 0030 am your methode is similar to my smearUpDown methode.
Problem is that this is constrained to just one vertical path and will produce some artifacts (like in this)

Current status is this baby:
climate now.jpg

Some tweaking needs to be done for sure :D
But I love how the warm air bends around the mountains :D

Feel free to play with the settings ;)
-------
Concerning Mapsize the number 128 km edge length was mentionned. This would be 8000 px edge length or 16 times zoom from current size - i can't imagine some imageprocessing being fast on this size. Additional problem: this is too big to store in ram permanently (I think it was sth about 0,5 gb...) so we'd have to save and load it in chunks or sth similar.

Other option would be zooming with factor 2-4. Then refining and then just interpolating to get the desired map size. We actually don't need too much details on this as it just shall provide the large scale landscape features.

ps: two dimensional arrays ftw :D
 

Laurimann

New Member
Contributor
World
You might wanna look at the climateSim repo I have on github.
I have it implemented this way at first, with some additional features.
Also there's something that takes the current heigth into account.
If I read this right at 0030 am your methode is similar to my smearUpDown methode.
Problem is that this is constrained to just one vertical path and will produce some artifacts (like in this)
Ah, i just looked at the Terasology git and saw not the commented pieces. Yes, seems very similiar - too bad it didn't work out. :( I was so excited about it. :D Oh well...

Great work Nym, anyhow, the heat map looks gorgeous! :)
 

Nym Traveel

Active Member
Contributor
Art
World
I won't lie to you. one can ofc tweak this smearing technique until you get something like on page 2 with
Code:
        smearUpDown(-1, size / 2);
        smearUpDown(1, 0);
        smearUpDown(-1,size);
        smearUpDown(1, size / 2);
        overlayHeight(0,0);
        oneBlurStep();
        oneBlurStep();
        oneBlurStep();
        overlayHeight(20, 30);
so basically the smears say in which direction and from where the smear should occur. Then overlay heigth with zero strength and zero heigth influence is just another methode of saying: make the ocean again a moderate climate.
then blur a few times and finally give the mountains some of their characteristics back.
But it looks just washed out and the artifacts are still visible :(
----
Thanks for the kind words :)
I like the general look of it, although i don't like the mountains. Also when I only compute distance from equator or poles the image looks more crisp in my eyes. I'll play with it some more every once in a while :)
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Curiously, how would a circular mountain chain near the equator work out? If the mountains are high enough can they "resist" the encroaching heat and leave an interior valley at lower than average temps?

Not sure that's realistic or desirable, it just came to mind for some reason. Could perhaps result in some sort of Tibet-type massive mountain area that remains chilly highlands despite being surrounded by tropics :)
 

Nym Traveel

Active Member
Contributor
Art
World
Yeah, this would be possible. I need some tweaking in how the results of the measurement affect the final outcome.
I can try it with the png to text programm Esereja wrote for matlab :)
 

Nym Traveel

Active Member
Contributor
Art
World
Good News:
I implemented the bicubic interpolation of the heigthmap and the option to scale it beyond 1 :)


bad news: i tried to just trick the system to load chunks +-1 to normal level but i failed there :D
 

Laurimann

New Member
Contributor
World
I'll also post something, especially after being encouraged to do so now. :)

So, i was playing with platec again (working on the age map thing) and accidentally this (attached) SUPER cool map popped up (and stupid me didn't take the heightmap dump, just screenshot)! So, i just wanted to share it because it is BEAUTIFUL!

2013-01-14-224648_512x512_scrot.png


I mean, just look at it: a richly shaped main land with a medium island right next to it and these two separated by a peaceful "mediterranean sea"! At the bottom a long and mountain decorated neck brings civilizations to a southern island governed by twin peaks. Marvelous! Not only that, but at left corner there's a lost island with amazingly perfect coastal mountain chain to the north of it! And far to the right there's a small treasure island waiting to be discovered.

And don't even start about the island chains, oh my lord! Long, long necklace starting from the north of our "Sicilica island" extends far to the east being rich in atolls and bays. From her south a straight line of small islands drip further south, each of them inhabited by lost tribes...

And the main land itself! Yes, it indeed is rich in curves and forms, dominated by its southern mountains that like tentacles separate nations from each other! Tall, white mountains form an impassable wall and small bodies of water that fill the valleys nourish and separate animals and herders alike. The less cloud piercing mountain ranges are as if lace or torn garment lifting all living things closer to the heavens with streams of water running vividly down their slopes into the vast plains of the north-east.

Yes, this map is truly magnificent! I do not stop marveling the capability of the simplest of simulations of plate tectonics to generate such amazingly inspiring topographies - topographies i've NEVER EVER seen any other (fully procedural) method to achieve. And i do not say this to glorify myself, but to share the joy of discovery with you fellows. :)
 

Esereja

Active Member
Contributor
Try to post something like that in heightmap, it would be usefull. Touhgt I can convert it to height map. It wont perfect conversion unfortunately.
 

Nym Traveel

Active Member
Contributor
Art
World
Some progress concerning maps:
First the good news: I (once again) rewrote the climate sim for more convenient results.
Current status on a 1024x1024 heigthmap:


You can grab it as usual on Github.
I would be interested in your console outputs, concerning speed (with a bit of data like cpu, ram).
should look like:
Code:
Reading file: 575 ms
Starting distance calculation: poles
Poles: 22030 ms
Starting distance calculation: equator
Equator: 22408 ms
Compose: 82 ms
Starting distance calculation: water
Humidity: 3967 ms
Climate: 48491 ms
Steep sides: 200 ms
Normalizing: 20 ms
Total time: 50144 ms
Second news is the overhaule of the WorldBiomeProvider Class.
I managed to write a new mapInfoProvider wich shall replace the upper class and exchange all occurences.
Two problems arised with this:
first of all my game just loaded one chunk and nothing around :)
and the performance on world loadup was crap...

solution:
after fiddeling around in 30-40 classes and i suspect some collateral damage done I decided to start fresh.
I think i will temporarely throw the old generators out and rethink the system from loadup.

Oh, and when i got some spare time i need to write the calculated maps to disk so they're not recalculated every loadup ;)
 

ddr2

New Member
Contributor
World
For me :
i7-620M -> dual core @ 2.66Ghz
8Gb ram

Code:
Reading file: 383 ms
Starting distance calculation: poles
Poles: 20809 ms
Starting distance calculation: equator
Equator: 21188 ms
Compose: 80 ms
Starting distance calculation: water
Humidity: 4469 ms
Climate: 46547 ms
Steep sides: 141 ms
Normalizing: 15 ms
Total time: 51805 ms
With -Xmx1024m (does not seems to matter much)


Code:
Reading file: 373 ms
Starting distance calculation: poles
Poles: 19918 ms
Starting distance calculation: equator
Equator: 22054 ms
Compose: 73 ms
Starting distance calculation: water
Humidity: 4540 ms
Climate: 46587 ms
Steep sides: 147 ms
Normalizing: 16 ms
Total time: 50578 ms
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
For Me:
- AMD Phenom II X2 550 @ 3.10 GHz
- 4GB RAM
- (some other tasks running in background, though)
- -Xmx1G

Code:
Reading file: 437 ms
Starting distance calculation: poles
Poles: 30944 ms
Starting distance calculation: equator
Equator: 31562 ms
Compose: 77 ms
Starting distance calculation: water
Humidity: 4433 ms
Climate: 67017 ms
Steep sides: 199 ms
Normalizing: 22 ms
Total time: 68995 ms
I'll post the result for my laptop later ;)
 

Cervator

Org Co-Founder & Project Lead
Contributor
Design
Logistics
SpecOps
Those maps are beautiful ! Is that warm bay with hot tropics bordered by mountains to the north on the left side really simulated that well with the heat being trapped by the mountains? That's awesome! I love how much more vibrant the details like that are now (more contrast due to mountains etc).

Should elevation impact to temperature in mountains themselves be made more extreme? I could imagine that sharp mountain chain dividing the hot jungle from temperate plains itself be a little more blue along the very spine of the mountain chain? Or would that not allow the heat to transfer to the other side as well / be handled by the height-map itself dropping temp with elevation?

Code:
Reading file: 391 ms
Starting distance calculation: poles
Poles: 18102 ms
Starting distance calculation: equator
Equator: 18662 ms
Compose: 54 ms
Starting distance calculation: water
Humidity: 6143 ms
Climate: 42963 ms
Steep sides: 199 ms
Normalizing: 19 ms
Total time: 44260 ms
Core i7 920 hyperthreaded quad @ 2.67 GHz
9 GB DDR3
1 GB SATA drive
No tweaks made to run config - pretty much identical with -Xmx1024m enabled (about a quarter second apart)
 

Nym Traveel

Active Member
Contributor
Art
World
Darn, you beat me cev :p

The temperature on top of the mountains is not very difficult to change - It's controlled via the overlayHeigth methode. Feel free to play with it ;)
The mountain chain orthogonal to the biggest chain in the north-west is unfortunately too low to be affected noticeable.


And thanks for the performance tests :)
 

Skaldarnar

Development Lead
Contributor
Art
World
SpecOps
Code:
Reading file: 517 ms
Starting distance calculation: poles
Poles: 23069 ms
Starting distance calculation: equator
Equator: 23582 ms
Compose: 80 ms
Starting distance calculation: water
Humidity: 4200 ms
Climate: 50932 ms
Steep sides: 215 ms
Normalizing: 25 ms
Total time: 52408 ms
On my laptop with Core i3 370M, 4GB RAM.
 

Laurimann

New Member
Contributor
World
As it states in http://donjon.bin.sh/world/about/

A sphere is repeatedly bisected along a random great circle, and one half elevated above the other. This process is repeated thousands of times, producing random terrain.
This is an old fractal terrain generation technique and as such possesses the well known strengths and weaknesses of fractal terrains (which i briefly reviewed in my thesis). The generated terrains are very nice, nonetheless. :)
 
Top