Fractal heightmaps: Now with Gui!
Fractal heightmaps: Now with Gui!
Hi all,
Ive been playing around with fractal algorithms to create heightmaps for ottd. Especially the 1 height difference limit makes it hard to have nice looking mountains (with peaks) in the game. I wrote a map generator using the plasma fractal (random midpoint displacement), while forcing it to make water edges to get some big continental shapes. Tell me what you think, I myself am quite happy with how mountain ranges look while still enough flat land to have a playable scenario.
Ingame example: The GUI should be really intuitive. Select some parameters, seeds and generate until you see something that suits you:
The results will be saved in a directory called 'output' and consist of both a coloured image and a greyscale image. The coloured looks nice, and the greyscale is for use in openttd.
If you encounter some nice maps/seeds, please share them here with the rest Also if you make improvements to the script, I would very much like to see those.
cheers
zooks
edit (09/04/13): added python source
edit (11/04/13): added link to png library
edit (18/04/13): uploaded the gui
Ive been playing around with fractal algorithms to create heightmaps for ottd. Especially the 1 height difference limit makes it hard to have nice looking mountains (with peaks) in the game. I wrote a map generator using the plasma fractal (random midpoint displacement), while forcing it to make water edges to get some big continental shapes. Tell me what you think, I myself am quite happy with how mountain ranges look while still enough flat land to have a playable scenario.
Ingame example: The GUI should be really intuitive. Select some parameters, seeds and generate until you see something that suits you:
The results will be saved in a directory called 'output' and consist of both a coloured image and a greyscale image. The coloured looks nice, and the greyscale is for use in openttd.
If you encounter some nice maps/seeds, please share them here with the rest Also if you make improvements to the script, I would very much like to see those.
cheers
zooks
edit (09/04/13): added python source
edit (11/04/13): added link to png library
edit (18/04/13): uploaded the gui
- Attachments
-
- mapgen.tar.gz
- The source code (executable python script + png library)
Depends on pygtk > 2.0 - (180 KiB) Downloaded 499 times
Last edited by zooks on 18 Apr 2013 17:28, edited 3 times in total.
Re: Fractal heightmaps
It seems very interesting, what about publishing more heightmaps?
Correct me If I am wrong - PM me if my English is bad
AIAI - AI for OpenTTD
AIAI - AI for OpenTTD
Re: Fractal heightmaps
Here you go, 65 heightmaps (30mb). Takes me around 4 minutes each to make them. I'm still thinking about adding rivers but I'm not sure how to make those look good without making the generation process take too long.
Re: Fractal heightmaps
That is rather cool. They certainly look better than the standard map generator...would it work for the More Heightlevels patch/ChillPP? Then you could do really huge mountains!
Temporary Permanent signature filling text. Content coming soon delayed indefinitely! Oh, and I have had a screenshot thread.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
Linux user (XMonad DWM/KDE, Arch), IRC obsessive and rail enthusiast. No longer building robots; now I ring church bells.
Author of an incredibly boring stickied post about NewGRFs.
-
- Tycoon
- Posts: 1534
- Joined: 14 Mar 2006 12:46
- Location: Netherlands
Re: Fractal heightmaps
any chance you could share sources for the generator?
Re: Fractal heightmaps
Realy cool, but I think you should get big rivers, (A bit like the rhine donau etc.)
See attached image.
Also I think cities are a bit concentrated too much at the plains. (Or only there). Some small flat low coasts would be great to get some hard to reach coastal villages.
The bottum aprt of that big lake already looks like a river, it reminded me about my holiday at the Mozel.
Edit:
ADVICE TOO ALL!
Go play this maps with you nicest GRF, they are so great. Finnally Make rail building a challange.
(1 small realistic railway line: 26 tunnels, 14 bridges and uncountable corners)
See attached image.
Also I think cities are a bit concentrated too much at the plains. (Or only there). Some small flat low coasts would be great to get some hard to reach coastal villages.
The bottum aprt of that big lake already looks like a river, it reminded me about my holiday at the Mozel.
Edit:
ADVICE TOO ALL!
Go play this maps with you nicest GRF, they are so great. Finnally Make rail building a challange.
(1 small realistic railway line: 26 tunnels, 14 bridges and uncountable corners)
- Attachments
-
- Geen naam, 01-01-1930.png
- (1.27 MiB) Downloaded 12 times
View my (train)pictures on Flickr
Re: Fractal heightmaps
With a few modifications it would indeed as it basically translates a 0 to 1 float value to 0 to 15 ints atm, though larger mountain areas are needed to get the higher peaks, maybe in combination with the extra large maps patch as well. If I generate a 256*256 map, mountains will be about half as high as 2048*2048 because there's less space..FLHerne wrote:That is rather cool. They certainly look better than the standard map generator...would it work for the More Heightlevels patch/ChillPP? Then you could do really huge mountains!
Sure I will, though preferably not in its current state, I want to make the code a bit more readable before sharing it and maybe add rivers and deal with some oddities. If youre really eager, pm me and Ill send you the source.ZxBiohazardZx wrote:any chance you could share sources for the generator?
The problem with rivers is that it is hard to come up with a set of rules like where they should start and how they should flow etc, if you have some pointers (weblinks) to useful algorithms, let me knowjor[D]1 wrote:Realy cool, but I think you should get big rivers, (A bit like the rhine donau etc.)
See attached image.
PS, did you downscale the map to 1024^2? It looks as if the mountains in the picture are less rough than normal..
I'm not sure why the flat plains are mostly concentrated in the centre, I can try to force the process into more flat land at the coast, but as everything is basically random this is hard. Some maps turn out with great flat coastlines while others have mostly hilly coasts.jor[D]1 wrote:Also I think cities are a bit concentrated too much at the plains. (Or only there). Some small flat low coasts would be great to get some hard to reach coastal villages.
Thanks , It indeed is more of a challenge to (realistically) find your way through the mountains.jor[D]1 wrote:Finnally Make rail building a challange.[/b]
(1 small realistic railway line: 26 tunnels, 14 bridges and uncountable corners)
Re: Fractal heightmaps
No, played on 20xx*20xx''
But, i use it with chill patchpack, which uses 256 colors for heightmaps. Maybe that makes them less rough, or it could just be coincidence, some maps had real rough costs with "boulders" in sea.
But, i use it with chill patchpack, which uses 256 colors for heightmaps. Maybe that makes them less rough, or it could just be coincidence, some maps had real rough costs with "boulders" in sea.
View my (train)pictures on Flickr
-
- Tycoon
- Posts: 1534
- Joined: 14 Mar 2006 12:46
- Location: Netherlands
Re: Fractal heightmaps
Mainly wondering because my previous realistic map attempt failed due to a harddrive issue, i am in need of a fast landscape generator that results into realisitc landscapes. i dont care if i have to after-edit it, i just need a plain heightmap that i can fill with rivers, cities, infra etc
similar to cindini, with a change of me not manually scaping the land, for im not that crazy
similar to cindini, with a change of me not manually scaping the land, for im not that crazy
Re: Fractal heightmaps
Hmm, yeah I see now, the problem is that the heightmaps are in the range of 255 but only define 15 levels in between, also ottd automatically smooths the slopes which makes it look less rough. To get it looking the same with the 256 height levels some things would have to change. I suggest you try it once with only 16 heightlevels, it looks betterjor[D]1 wrote:No, played on 20xx*20xx''
But, i use it with chill patchpack, which uses 256 colors for heightmaps. Maybe that makes them less rough, or it could just be coincidence, some maps had real rough costs with "boulders" in sea.
PM'd you the sourceZxBiohazardZx wrote:Mainly wondering because my previous realistic map attempt failed due to a harddrive issue, i am in need of a fast landscape generator that results into realisitc landscapes. i dont care if i have to after-edit it, i just need a plain heightmap that i can fill with rivers, cities, infra etc
similar to cindini, with a change of me not manually scaping the land, for im not that crazy
-
- Tycoon
- Posts: 1534
- Joined: 14 Mar 2006 12:46
- Location: Netherlands
Re: Fractal heightmaps
hmmz i cant get a nice looking 4k*4k out of it, it works ok for the 2k*2k, but on 4k's it isnt popping something i like yet...
Re: Fractal heightmaps
Im in nepal at the moment so lots of inspiration here. When Im back I'll get back on this, and will look how easy it is to adjust for larger mapsizes and more heightlevels. Right now it was really focussed on 2048, and down to 512 it looks fine but outside that range it turns bad indeed. If anyone knows some good information sources on natural map/river/town generation, please share it with me
Re: Fractal heightmaps
Sorry to say, but likely the mountains generated are too sharp for OTTD slopes ? Because its a quite large problem when the slopes becomes too much...
Aanyway, maybe some extra large map patches can overcome those...
Aanyway, maybe some extra large map patches can overcome those...
YNM = yoursNotMine - Don't get it ?
「ヨーッスノットマイン」もと申します。
「ヨーッスノットマイン」もと申します。
Re: Fractal heightmaps
The generation process is limited to 15 heightlevels and afterwards gets adjusted to openttd slopes so what you see on the previews is pretty much what you get ingame.Yoursnotmine wrote:Sorry to say, but likely the mountains generated are too sharp for OTTD slopes ? Because its a quite large problem when the slopes becomes too much...
Aanyway, maybe some extra large map patches can overcome those...
A problem though is that there seem to be no parameters that specify things like continent size, number of continents/islands, variety distribution. This is probably because I don't understand the (diamond square) fractal enough.
Re: Fractal heightmaps
Here is the python code (2.7.x). Not documented and not really readable, no guarantees.
The call should look something like this:
width and height can range from 1(128) to 5(2048)
seedstart and seedend are the seeds given to the random generator. If both left empty, the script will produce one random map called test.png
example: to create 100 maps 1024*512, you would use:
This results will be saved in a directory called 'output', and you have to create this directory (once) yourself if it is not there.
The results will be both a coloured image and a greyscale image. The coloured looks nice, and the greyscale is to use in openttd.
If you encounter some nice maps, please share them here with the rest Also if you make improvements to the script, I would very much like to see those.
cheers
zooks
The call should look something like this:
Code: Select all
python mapgen.py <width> <height> [seedstart] [seedend]
seedstart and seedend are the seeds given to the random generator. If both left empty, the script will produce one random map called test.png
example: to create 100 maps 1024*512, you would use:
Code: Select all
python mapgen.py 4 3 100 200
The results will be both a coloured image and a greyscale image. The coloured looks nice, and the greyscale is to use in openttd.
If you encounter some nice maps, please share them here with the rest Also if you make improvements to the script, I would very much like to see those.
cheers
zooks
Re: Fractal heightmaps
I really don't how i get this working...
Re: Fractal heightmaps
That's not much of a question, can you tell me what the problem is? What python version are you using? What operating system? I can help you if you're on linuxMisterX wrote:I really don't how i get this working...
Re: Fractal heightmaps
I just downloaded python 2.7.4 for this. Have no experience with python, so maybe I do something stupid...
Operation system is Windows 7, not linux.
I googled to found how to run a .py file and found the following:
Then i tried the first option (ofcourse with mapgen instead of xxxx). But i get 'SyntaxError: invalid syntax' and the : is highlighted in red.
The same happens when i add 4 3 100 200 (the same numbers as in your example) after it. Same error happens....
Thus tried the second option. When I press F5, also a error occurs:
Hope you see my mistake...
Operation system is Windows 7, not linux.
I googled to found how to run a .py file and found the following:
This help was for python 2.3.x, so i have to change the python23 to python27, i guess and i placed mapgen.py in c:\python23\On windows platform, you have 2 choices:
1.
In a command line terminal, type
c:\python23\python xxxx.py
2.
Open the python editor IDLE from the menu, and open xxxx.py, then press F5 to run it.
Then i tried the first option (ofcourse with mapgen instead of xxxx). But i get 'SyntaxError: invalid syntax' and the : is highlighted in red.
The same happens when i add 4 3 100 200 (the same numbers as in your example) after it. Same error happens....
Thus tried the second option. When I press F5, also a error occurs:
So somewhere i do something wrong... Maybe i place the map output at a wrong place? Where must i create that map?Traceback (most recent call last):
File "C:\Python27\mapgen.py", line 5, in <module>
import sys,os,png,random,colorsys,math,time
ImportError: No module named png
Hope you see my mistake...
Re: Fractal heightmaps
Ah I see now. I totally forgot to mention that it uses the pypng module/library. ApologiesMisterX wrote: Thus tried the second option. When I press F5, also a error occurs:So somewhere i do something wrong... Maybe i place the map output at a wrong place? Where must i create that map?Traceback (most recent call last):
File "C:\Python27\mapgen.py", line 5, in <module>
import sys,os,png,random,colorsys,math,time
ImportError: No module named png
Hope you see my mistake...
Easy fix: put this file: http://pypng.googlecode.com/svn/trunk/code/png.py
in the same directory as mapgen.py
After that, it should work. Let me know if this helps.
cheers
Re: Fractal heightmaps
1 gives still an error, i think a do still something wrong, but with 2 i can make maps. But then he used the predefined sizes. Standard 256x256, so the first time i tried 2, i get a 256x256 map. But in mapgen.py, i easiely can change the standard, so as second a 2048 x 2048 was made. So i can make some heightmaps with it.On windows platform, you have 2 choices:
1.
In a command line terminal, type
c:\python23\python xxxx.py
2.
Open the python editor IDLE from the menu, and open xxxx.py, then press F5 to run it.
Thanks for this tool, very usefull.
How big could you choose seedstart and seedend? Are there some limits?
Who is online
Users browsing this forum: No registered users and 24 guests