TerraGenesis Perlin
Moderator: OpenTTD Developers
TerraGenesis Perlin
Here is the TerraGenesis patch with Perlin noise. It creates some really lovely terrains, and is a complete replacement for the current terrain generator. There is a new switch panel in the Configure Patches for "Terrain", letting you switch between the original and new terrain generator.
TerraGenesisP works in the Scenario Editor and the main "New Game" selection. I havent tried starting a new network game with it, but it should work there as well.
The terrain generation works off 4 main variables:
Random seed: TGP terrains are not truly random - but use a random seed between 0..65535. You can enter this directly, or press the "Random" button to get a new one.
Terrain Type: Very Flat - Mountainous. This sets the maximum amplitude permitted. Due to the way the Perlin noise is created, you may have a flat area for your mountainous terrain. If this is the case, try a different random seed.
Sea Level: Very Low - High. This raises or lowers the apparent sea level, and re-scales the land to match. Again, the Perlin noise generator may give you a massive ocean on "Very Low", or a mountainous plateau with no water on "High" (unlikely).
Smoothness: Very Smooth - Very Rough. This sets how much variation you will have from little variation, to many smaller variations.
I also include the Landscape type selection, and the map size dropdowns on the Landscape Generation screen.
The great thing about this in the Scenario Editor, is that you can keep the same random terrain but try it in SubArctic, Tropical, Toyland, etc. When you are happy with the terrain in the Scenario Editor, nip back to the main menu, and start a New Game with those terrain parameters.
Tropical has a special feature to ensure that some areas are desert. Starting at halfway across the map (diagonally), the maximum terrain height is reduced steadily (its actually a COSine wave), until the terrain is lower and flatter. This can have the effect of flattenning the only mountains in the map - I may add a ON/Off button for this feature later.
Also, as the randomness is predictable, you can "share" a map by just giving its seed number. Click on the blue seed, and enter a new number. Try it with the "8918" terrain in the example pictures.
Please Note: this code is still in development, and contains commented sections that will eventually be removed from the final patch.
Have fun with it. Please tell me of some really good terrains you find. (I like 55123 on a large map size - good variety of mountains and sea.)
[edit] Latest update, Mar 14, 2006. Much improved mountains and lakes handling, added map border randomisation. Pretty much there.
[edit] Mar 15, 2006: Further improvements on the coastline, bug fixes.
I have also changed the behaviour of the Desert terrain. It now produces a desert valley between two ranges of mountains (on mountainous/hilly). As usual, desert climate doesnt respond well to "flat" or "very flat", as the whole map tends to go desert.
[edit] further update: Added patch setting for "Max distance from edge for Oil Refineries". With the more indented / uneven map edges, it was finding it difficult to place the oil refineries. This lets you select how far from the edge they can be: range 12-48. (default 16).
Also made New Game pick a random number for the seed, but Scenario Editor keeps last used.
[edit] Mar 28. A few minor edits. Added ability to set random seed in config file. Also, if seed=0, TGP picks a random seed. Ideal for dedicated server.
TerraGenesisP works in the Scenario Editor and the main "New Game" selection. I havent tried starting a new network game with it, but it should work there as well.
The terrain generation works off 4 main variables:
Random seed: TGP terrains are not truly random - but use a random seed between 0..65535. You can enter this directly, or press the "Random" button to get a new one.
Terrain Type: Very Flat - Mountainous. This sets the maximum amplitude permitted. Due to the way the Perlin noise is created, you may have a flat area for your mountainous terrain. If this is the case, try a different random seed.
Sea Level: Very Low - High. This raises or lowers the apparent sea level, and re-scales the land to match. Again, the Perlin noise generator may give you a massive ocean on "Very Low", or a mountainous plateau with no water on "High" (unlikely).
Smoothness: Very Smooth - Very Rough. This sets how much variation you will have from little variation, to many smaller variations.
I also include the Landscape type selection, and the map size dropdowns on the Landscape Generation screen.
The great thing about this in the Scenario Editor, is that you can keep the same random terrain but try it in SubArctic, Tropical, Toyland, etc. When you are happy with the terrain in the Scenario Editor, nip back to the main menu, and start a New Game with those terrain parameters.
Tropical has a special feature to ensure that some areas are desert. Starting at halfway across the map (diagonally), the maximum terrain height is reduced steadily (its actually a COSine wave), until the terrain is lower and flatter. This can have the effect of flattenning the only mountains in the map - I may add a ON/Off button for this feature later.
Also, as the randomness is predictable, you can "share" a map by just giving its seed number. Click on the blue seed, and enter a new number. Try it with the "8918" terrain in the example pictures.
Please Note: this code is still in development, and contains commented sections that will eventually be removed from the final patch.
Have fun with it. Please tell me of some really good terrains you find. (I like 55123 on a large map size - good variety of mountains and sea.)
[edit] Latest update, Mar 14, 2006. Much improved mountains and lakes handling, added map border randomisation. Pretty much there.
[edit] Mar 15, 2006: Further improvements on the coastline, bug fixes.
I have also changed the behaviour of the Desert terrain. It now produces a desert valley between two ranges of mountains (on mountainous/hilly). As usual, desert climate doesnt respond well to "flat" or "very flat", as the whole map tends to go desert.
[edit] further update: Added patch setting for "Max distance from edge for Oil Refineries". With the more indented / uneven map edges, it was finding it difficult to place the oil refineries. This lets you select how far from the edge they can be: range 12-48. (default 16).
Also made New Game pick a random number for the seed, but Scenario Editor keeps last used.
[edit] Mar 28. A few minor edits. Added ability to set random seed in config file. Also, if seed=0, TGP picks a random seed. Ideal for dedicated server.
- Attachments
-
- New Terrain Generation interface
- ss0TgenPv1.png (41.18 KiB) Viewed 19889 times
-
- Desert terrain map. Mountains reduce smoothly to a desert valley, then back up to mountains. (on Mountainous of course!)
- Unnamed, 1st Jan 1994.png (23.55 KiB) Viewed 18797 times
-
- TerraGenesisPerlin_5048.patch
- TGP at 5048
- (50.38 KiB) Downloaded 766 times
Last edited by richk67 on 30 May 2006 21:44, edited 10 times in total.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
E:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\Math.h(154) : error C2373: 'myabs' : redefinition; different type modifiers
E:\Open TTD Dev\Build terra genesis perlin\macros.h(135) : see declaration of 'myabs'
E:\Open TTD Dev\Build terra genesis perlin\landscape.c(680) : error C2065: 'M_PI' : undeclared identifier

on last SVN with just your patch...
is the bug coming from my Math.h ?
Its probably the way that M$ mangles Math.h in MSVC.Gedemon wrote:E:\Program Files\Microsoft Visual Studio\VC98\INCLUDE\Math.h(154) : error C2373: 'myabs' : redefinition; different type modifiers
E:\Open TTD Dev\Build terra genesis perlin\macros.h(135) : see declaration of 'myabs'
E:\Open TTD Dev\Build terra genesis perlin\landscape.c(680) : error C2065: 'M_PI' : undeclared identifier![]()
on last SVN with just your patch...
is the bug coming from my Math.h ?
Can someone else who knows MSVC help? Im really a fairly noobie at C/C++ and only have experience with Msys (& Cygwin a little).
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
ok, I've removed from landscape.c and added in the same file, and it seems to work.
are you using math.h for something else than M_PI ?
Code: Select all
#include "Math.h"
Code: Select all
#define M_PI 3.1415926535897932384626433832795
are you using math.h for something else than M_PI ?
COS function, pow function. I think thats all. (Although the pow is experimental, I think I current raise to x^1. This is so I can change it to 1.1 or whatever in future.)Gedemon wrote:ok, I've removedfrom landscape.c and addedCode: Select all
#include "Math.h"
in the same file, and it seems to work.Code: Select all
#define M_PI 3.1415926535897932384626433832795
are you using math.h for something else than M_PI ?
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
It still doesn't make rivers or mountainious vs flat areas, it's only more generating options now 

Don't panic - My YouTube channel - Follow me on twitter (@XeryusTC) - Play Tribes: Ascend - Tired of Dropbox? Try SpiderOak (use this link and we both get 1GB extra space)

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone

OpenTTD: manual #openttdcoop: blog | wiki | public server | NewGRF pack | DevZone







You're welcome to write your improved versionXeryusTC wrote:It still doesn't make rivers or mountainious vs flat areas, it's only more generating options now

Of course, its only 65536 terrains x 4 landscapes x 4 height levels x 4 sea levels x 4 smoothnesses. And when you increase the map size, more terrain appears. Millions of options, and more control and better quality than the current rectangular block terrain.
If there is something specific about terrain you want, be specific. Very specific. Do you want a generator that will give you a mountain, a flat bit, and some coast in each map? How do you recommend these are generated? What about when you dont want any mountains? etc.
As I said in the OP, the code is still in development. If you can help with specific and detailed suggestions - a river generator may be possible, for instance - then I may be able to code it.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
-
- Tycoon
- Posts: 11501
- Joined: 20 Sep 2004 22:45
OMG, when you told about
Maybe how that terrain generator looks can be used as inspiration.
I immidiatly tought about the land generator of SimCity3000 (or 4 if you like)Do you want a generator that will give you a mountain, a flat bit, and some coast in each map? How do you recommend these are generated? What about when you dont want any mountains?

Maybe how that terrain generator looks can be used as inspiration.

LOL - the Perlin bit worked first time and since it was a modified version of an existing code, took only about 2-3 hours to do.Brianetta wrote:Well done, Rich, that's clearly a huge piece of effort which appears to be finally paying off.
The user interface was an absolute nightmare... took many hours (10+) of fiddling!
I would really appreciate feedback as to whether the maps it generates are what you want as players. Or whether the 50/50 split mountain/flat terrains are preferable, but perhaps with more irregular non-rectangular bumps?
Ideas, as always, gratefully recieved... (then ignored

OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
if you are not using myabs, you can alway do
also I don't think the user should use non-random random seeds. It should just pick a random one when starting to generate a map
Code: Select all
#undef myabs
#include <Math.h>
except how to store that the game already started and somebody did some terraforming to place a road or railroad with no hills and you are screwed if you only transfer so few parametersprissi wrote:However to transfer a so created map over the net, you would only need for parameters: random start and the three settings. Could not save much more than this.
I think its more for being able to discuss a map before hand... eg. "Look at map 55123 on 128x128, Mountainous. Shall we do that in Sub artic? Any prefs on sea-level?"Bjarni wrote:except how to store that the game already started and somebody did some terraforming to place a road or railroad with no hills and you are screwed if you only transfer so few parametersprissi wrote:However to transfer a so created map over the net, you would only need for parameters: random start and the three settings. Could not save much more than this.
The one major hiccup at the moment is that I dont randomise the seed on first load, so it always starts at 0. I could have it that the seed is randomised for New Game, since you can always type in a preferred seed to override the random one.
OTTD NewGRF_ports. Add an airport design via newgrf.Superceded by Yexo's NewGrf Airports 2
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
Want to organise your trains? Try Routemarkers.
--- ==== --- === --- === ---
Firework Photography
whow. whow, whow, whow, whow. this is so awesome i can't describe it :=) it takes the feeling of the game to the next level. very cool patch!!!
now if someone would add support for all three climate types into one map ..... *dreaming of openttd future* :=)
edit:
here's a compiled win32 binary if you want to check it out...
http://rrs.at/m/openttd.zip
now if someone would add support for all three climate types into one map ..... *dreaming of openttd future* :=)
edit:
here's a compiled win32 binary if you want to check it out...
http://rrs.at/m/openttd.zip
to everyone who's coding on openttd: YOU ROCK !!!
-
- Tycoon
- Posts: 1966
- Joined: 21 May 2004 07:39
- Location: Singapore
- bobingabout
- Tycoon
- Posts: 1850
- Joined: 21 May 2005 15:10
- Location: Hull, England
i kinda like the look of this, not tried it yet, but maybe i should.
JPG SUX!!! USE PNG!!!
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.
[/url]
There are times when JPG is useful, TTD screenshots is not one of them. Please use PNG instead.
[/url]
The generator in the IN is certainly more unpredictable heh. It practically forces you to level large areas just to lay track because of the randomness.
This is much smoother, much more realistic; and should allow even large networks without having to make huge changes to the land.
Biggest problem i have with it after playing a bit, is that its probably too smooth in a lot of cases. Even with it set to mountainous/very rough, I struggled to get defined mountain/valleys in most cases (pic1).
Whatever you're using for the coastlines works great though (pic2).
This is much smoother, much more realistic; and should allow even large networks without having to make huge changes to the land.
Biggest problem i have with it after playing a bit, is that its probably too smooth in a lot of cases. Even with it set to mountainous/very rough, I struggled to get defined mountain/valleys in most cases (pic1).
Whatever you're using for the coastlines works great though (pic2).
- Attachments
-
- screenshot2.png
- (79.31 KiB) Downloaded 870 times
-
- screenshot1.png
- (84.09 KiB) Downloaded 925 times
I tried it as well, and with the temperate terrain it generated a lot of antenna's, like 1 in every 10x10 square. So that has to be finetuned...
Other than that, the terrain looks absolutely smahsing, a really nice map to play on, and I wouldn't want it any other way!
Other than that, the terrain looks absolutely smahsing, a really nice map to play on, and I wouldn't want it any other way!
"I'm gonna rip his leg off and kick him with it!", Sanjuro, Shogo-MAD
Who is online
Users browsing this forum: No registered users and 18 guests