[Idea and Method] Improved heightmap generation
Moderator: OpenTTD Developers
[Idea and Method] Improved heightmap generation
Hi all!
So one thing which bugs me about the terrain generation in OpenTTD is that there is no long distance variation... the maps feel very bland with few landmarks. I think the most fundamental cause of this is the terrain hillyness is uniform across all terrain, you don't get ranges of hills and mountains don't feel like mountains. While I can't program I can do image manipulation, and given the terrain generation starts life as perlin noise (or so I assume) all the following image processing steps I am going to talk about should be directly analagous.
1. Perlin noise. Bland, boring scaleless. The current terrain generator essentially stops here.
2. Curves. Apply a curves intensity modification.
Modification of this curve will give different terrain properties, you just need to shift the control points.
Shifting the second point horizontally: Controls quantity of water
Shifting the third point vertically: Controls the hillyness of hilly terrain
Shifting the fourth point horizontally: Controls the quantity and extensiveness of mountains
Shifting the fifth point vertically: Controls the height of mountainous terrain
3. Modified noise. More varied; now with lakes and mountain ranges!
So one thing which bugs me about the terrain generation in OpenTTD is that there is no long distance variation... the maps feel very bland with few landmarks. I think the most fundamental cause of this is the terrain hillyness is uniform across all terrain, you don't get ranges of hills and mountains don't feel like mountains. While I can't program I can do image manipulation, and given the terrain generation starts life as perlin noise (or so I assume) all the following image processing steps I am going to talk about should be directly analagous.
1. Perlin noise. Bland, boring scaleless. The current terrain generator essentially stops here.
2. Curves. Apply a curves intensity modification.
Modification of this curve will give different terrain properties, you just need to shift the control points.
Shifting the second point horizontally: Controls quantity of water
Shifting the third point vertically: Controls the hillyness of hilly terrain
Shifting the fourth point horizontally: Controls the quantity and extensiveness of mountains
Shifting the fifth point vertically: Controls the height of mountainous terrain
3. Modified noise. More varied; now with lakes and mountain ranges!
Re: [Idea and Method] Improved heightmap generation
4. Final terrain.
Top points of this generation method:
* Simple extension of existing code:
* Could simply rescale existing terrain...
* ... or be a new implementation using 255 height steps, rescaling, and application via heightmap code.
* Improves gameplay:
* Adds additional obstacles to construction...
* ... while opening up new passes/regions of flat land for constrution.
* Feels more interesting to play:
* Looks and feels more like real terrain.
I think this is a lot more interesting (at very little cost) than the current terrain generation.
Top points of this generation method:
* Simple extension of existing code:
* Could simply rescale existing terrain...
* ... or be a new implementation using 255 height steps, rescaling, and application via heightmap code.
* Improves gameplay:
* Adds additional obstacles to construction...
* ... while opening up new passes/regions of flat land for constrution.
* Feels more interesting to play:
* Looks and feels more like real terrain.
Re: [Idea and Method] Improved heightmap generation
if you can extract the mathematical representation of the image transformation, i'm sure it should be possible to port that to tgp [the landscape generator]
Re: [Idea and Method] Improved heightmap generation
I like this idea, the only downside I see to it is OpenTTD's somewhat limited means of defining heights - limited by way of the fact that you cannot have sharp hills and gentle hills, it's all done in steps.
While I understand that's never going to be easy to change, it does suggest that at least a partial implementation of cliffs could help. Partial, because until the unlikely event of viewport rotation happens, only the frontal two views could ever really be done properly.
I'd like to see this ingame though. Can I ask though, that image of the final product - what's that generated with?
While I understand that's never going to be easy to change, it does suggest that at least a partial implementation of cliffs could help. Partial, because until the unlikely event of viewport rotation happens, only the frontal two views could ever really be done properly.
I'd like to see this ingame though. Can I ask though, that image of the final product - what's that generated with?
Re: [Idea and Method] Improved heightmap generation
What you need for more interesting terrain would be the MoreHeights patch and a rewritten TGP.
Re: [Idea and Method] Improved heightmap generation
For input perlin noise values of 0-255:For resulting heightmap values of 0-255:
Water quantity:
x1=0 to 192
almost no water to approx 3/4 water
Hill height:
y2=32 to 192
hills of approx 4 to 12 in height
Proportion of mountains:
x2=x1 to 224
all mountains to very few mountains
Height of mountains
y3=y2 to 255
mountains of hill height to maximum height
To convert the typical values to other scales (eg. y values to OpenTTD heights 0-15) simply scale 0-255 for all corresponding variables (in this case y2, y3) to the new range.
Code: Select all
x=perlin noise value at a point
Code: Select all
y=resulting terrain height at that point
Code: Select all
control point 0: (0, 0)
control point 1: (x1, 0)
control point 1: (x2, y2)
control point 1: (255, y3)
Code: Select all
if (x<=x1) {
y=0;
} else if (x>x1 && x=x2) {
y=y1+(x-x1)*(y2-y1)/(x2-x1);
} else {
y=y2+(x-x2)*(y3-y2)/(x3-x2);
}
x1=0 to 192
almost no water to approx 3/4 water
Hill height:
y2=32 to 192
hills of approx 4 to 12 in height
Proportion of mountains:
x2=x1 to 224
all mountains to very few mountains
Height of mountains
y3=y2 to 255
mountains of hill height to maximum height
To convert the typical values to other scales (eg. y values to OpenTTD heights 0-15) simply scale 0-255 for all corresponding variables (in this case y2, y3) to the new range.
That was made with the interactive surface plotter (essentially a heightmap plot) with a custom surface texture (blue/green according to height) in ImageJ. It is a Java image editing program designed for scientific (particualarly microscopy) image analysis, manipulation and quantification. I like it because it has a very powerful macro/scripting language for image editing and analysis.Gremnon wrote:Can I ask though, that image of the final product - what's that generated with?
See attachment for an in-game demonstration of the above heightmap...Gremnon wrote:I'd like to see this ingame though.
- CommanderZ
- Tycoon
- Posts: 1872
- Joined: 07 Apr 2008 18:29
- Location: Czech Republic
- Contact:
Re: [Idea and Method] Improved heightmap generation
The mathematical basis of such transformation is fairly trivial - it is like 3 lines of code (as long as you don't need fancy splines to define the transformation), you just have to map the original values onto transformed values.Eddi wrote:if you can extract the mathematical representation of the image transformation, i'm sure it should be possible to port that to tgp [the landscape generator]
Wait a few days, there will be will a bigger gun for you to play with then.
Re: [Idea and Method] Improved heightmap generation
I do not see, how this method can generate long distance variation. All it does is apply a different scaling to the height levels. It does not change the location of hills/mountains. It only modifies their shape.
Re: [Idea and Method] Improved heightmap generation
It exaggerates the effect of rare (very bright/high) regions on the heightmap so "feels" more varied. Mathematically (eg. fourier analysis) will still show the same minimum frequency cutoff as the original heightmap.
Re: [Idea and Method] Improved heightmap generation
Here is an implementation for the TGP landscape generator, using a fixed complex curve map.
- Attachments
-
- heightcurves.diff
- (1.6 KiB) Downloaded 194 times
He's like, some kind of OpenTTD developer.
Re: [Idea and Method] Improved heightmap generation
The mountains are quite sudden on this method, I would like it more if they could be kept more fluently.
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
Re: [Idea and Method] Improved heightmap generation
I like it better this way. In conjunction with More Height Levels, this could provide some interesting maps.
Re: [Idea and Method] Improved heightmap generation
This is a matter of tweaking the curves, if you increase the height of the hills the mountains will be less "sudden". A hill height of 128 and a proportion of mountains of (255-x1)/2 will give you vanilla OpenTTD no sharp start to mountains.The mountains are quite sudden on this method, I would like it more if they could be kept more fluently.
Excellent, now just have to get OpenTTD compiling under my new win7 install :sHere is an implementation for the TGP landscape generator, using a fixed complex curve map.
Re: [Idea and Method] Improved heightmap generation
Very nice idea Zephyris.
I tried this with the more height levels patch and so far the generated terrain looks amazing.
petern,
Trunk please.
If not can I steal your code please ?
I tried this with the more height levels patch and so far the generated terrain looks amazing.
petern,
Trunk please.
If not can I steal your code please ?
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Re: [Idea and Method] Improved heightmap generation
With some curve preset values for the different standard terrain options (ie. sea level, flatness, [roughness is unchanged]) would this have a chance for trunk?
Re: [Idea and Method] Improved heightmap generation
Possibly. This new version has four curves which are randomly selected and applied in a non-linear manner across the map, providing a boost of variety across the map. It deviates from your original curve 'template' a bit.
Some sample screenshots of maps produced:
http://fuzzle.org/~petern/ottd/variety2.png
http://fuzzle.org/~petern/ottd/variety3.png
http://fuzzle.org/~petern/ottd/variety4.png
http://fuzzle.org/~petern/ottd/variety5.png
Some sample screenshots of maps produced:
http://fuzzle.org/~petern/ottd/variety2.png
http://fuzzle.org/~petern/ottd/variety3.png
http://fuzzle.org/~petern/ottd/variety4.png
http://fuzzle.org/~petern/ottd/variety5.png
- Attachments
-
- heightcurves2.diff
- (7.09 KiB) Downloaded 157 times
He's like, some kind of OpenTTD developer.
Re: [Idea and Method] Improved heightmap generation
Lookin great, now to find a way to prevent towns being built on unsuitable locations and make smoother coast lines.
Re: [Idea and Method] Improved heightmap generation
I think that looks really good, esp. variety2.png, though that may be because the terrain can more clearly be seen.
Re: [Idea and Method] Improved heightmap generation
petern.
Could it be that STR_TERRAIN_TYPE_MIXED slipped in trunk by accident?
I did not see it being used other than in v2?
Offcourse from v2 (and trunk now) it does not work with the more height levels patch enabled.
(Terrain gets clipped at level 16 if I apply variation, I think I need to add a swith somewhere,
but that discussion does not belong here.)
Could it be that STR_TERRAIN_TYPE_MIXED slipped in trunk by accident?
I did not see it being used other than in v2?
Offcourse from v2 (and trunk now) it does not work with the more height levels patch enabled.
(Terrain gets clipped at level 16 if I apply variation, I think I need to add a swith somewhere,
but that discussion does not belong here.)
-- .- -.-- / - .... . / ..-. --- .-. -.-. . / -... . / .-- .. - .... / -.-- --- ..- .-.-.-
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
--- .... / -.-- . .- .... --..-- / .- -. -.. / .--. .-. .- .. ... . / - .... . / .-.. --- .-. -.. / ..-. --- .-. / .... . / --. .- ...- . / ..- ... / -.-. .... --- --- -.-. .... --- --- ... .-.-.- / ---... .--.
Playing with my patchpack? Ask questions on usage and report bugs in the correct thread first, please.
All included patches have been modified and are no longer 100% original.
Who is online
Users browsing this forum: No registered users and 0 guests