Alpha Centauri 2

Sid Meier's Alpha Centauri & Alien Crossfire => Modding => Bug/Patch Discussion => Topic started by: Flygon on September 18, 2012, 04:47:36 PM

Title: Generating maps based off PNG heightmaps?
Post by: Flygon on September 18, 2012, 04:47:36 PM
Oh hey! I just noticed this forum existed... so much for posting at CGN! Anyway, I'll just quote the thread I made on CGN (http://www.civgaming.net/forums/showthread.php?t=7851) below, since it's 1:45AM and I can't be stuffed rewriting the post to make sense for this forum.

Quote
Oh hey, a sudden absolutely random post from Flygon! Anyway, I'd like to inquire about a question. Specifically, the ability to generate 'random' maps based off greyscale heightmaps. If this sounds at all familiar, it's because I am ripping the idea completely from OpenTTD (http://wiki.openttd.org/Heightmap), and as it turns out, SMAC/X and OpenTTD generate their maps using the exact same method. :p Except, of course, SMAC/X can generate much smoother heightmaps with actual 3D tiles.

Of course, the major impediment to this whole idea, is, of course... there no tools for converting PNG files into a heightmap-only SMAC/X scenario file. So, I'd like to ask... is there actually any tools for achieving this? And if not... where is scient and when can I beg him to help make the suitable tools? :cool:

It cannot be all that difficult, given it's a 2D heightmap... right... right?

Edit: Going by my calculations, it should be possible to generate maps based off PNG heightmaps to just every 1.5ish 10 meter segments being off by 10 meter. Given how absolutely minimal this is... well, it's pretty darn good. And it's extremely easy and simple to generate greyscale heightmaps based off real-world locations anyway.


I know this is a bit of a whacky first post, and I'm aware an external program isn't exactly a mod... but given the overall context of things, this seems the right place and way to do things.

Nice spambot protection, by the way! ;3
Title: Re: Generating maps based off PNG heightmaps?
Post by: Buster's Uncle on September 18, 2012, 08:58:52 PM
The bots don't give us any trouble, to the extent that my partner doesn't want me going to the trouble to hammer them.(http://alphacentauri2.info/index.php?action=dlattach;topic=2283.0;attach=641)

This is interesting research; I'm a creative guy, not a technical one, so I have little to say, but will pass it along to scient and be following this with great interest.
Title: Re: Generating maps based off PNG heightmaps?
Post by: Flygon on September 19, 2012, 02:33:15 AM
Excellent! It has been too long since I've spoken to scient... finding this community has been a godsend!

Only real huge concern I have with the heightmaps are that PNG's are based on a horizontal-vertical grid... Alpha Centauri has a grid-type that'd only find a diamond-shape of that PNG useful (it's hard to explain) unless the grid was rotated on a 45 degree angle first... but given how the heightmap system in Alpha Centauri should work anyway, and how easy it is to get high-resolution heightmaps that can be rotated and scaled-down accurately anyway without any issues... sorry, rambling on a bit here. I'll need to get off my ass and find the IRC channel. :P
Title: Re: Generating maps based off PNG heightmaps?
Post by: Buster's Uncle on September 19, 2012, 03:29:29 AM
Check the top of the page - third item.  I hear you have to hang around a while to get a conversation going on IRC.
Title: Re: Generating maps based off PNG heightmaps?
Post by: Kilkakon on September 19, 2012, 05:13:49 AM
Good to see you again Flygon. :)

Yeah IRC seems to be a bit of a stakeout operation at times to get anybody. Still, good luck doing it. :)

If the SMAC map format has been posted somewhere, it shouldn't be too hard to convert an image to it though (I could do that if I had specifications to look at)
Title: Re: Generating maps based off PNG heightmaps?
Post by: Flygon on September 19, 2012, 05:57:52 AM
Good to see you again Flygon. :)
Hey there! I must say, when I heard you talk with Charem, I was quite surprised! :o
Quote
If the SMAC map format has been posted somewhere, it shouldn't be too hard to convert an image to it though (I could do that if I had specifications to look at)
Time for the hex editor! Gotta poke those bytes til we got something working! ;D

This heightmap thing has been absolutely jammed in my mind, I keep thinking of how to get more precision out of the heightmaps now! But I've also realized one serious problem.

There is no way to get the depth of the oceans working with greyscale heightmaps. I'll need to look into methods of obtaining ocean depth... might be necessary to draw that up manually, though.
Title: Re: Generating maps based off PNG heightmaps?
Post by: Kilkakon on September 19, 2012, 06:17:13 AM
Charem? Haha well he has disappeared again--he's pleasant when he's around but yeah... haha

How about having a set depth for water, at like 127/255?

And yeah, I'd want a format if I was going to write a converter from raw or whatever.
Title: Re: Generating maps based off PNG heightmaps?
Post by: Flygon on September 19, 2012, 06:34:22 AM
The main issue is, is that all the tools I have for generating real-world heightmaps, they don't actually seem to retain oceanographic data, outside of rivers. Admittedly, the tools I'm using, I've only been taught to use in context of OpenTTD (which has no ocean heightmap levels, and uses the raw PNG's as heightmaps). What ends up defined as water/ocean is when the height level is set to 0 (and 1-15 also, for the context of OpenTTD, but Alpha Centauri has far more than 16 levels of precision).

If we were to make the heightmap tool work off a greyscale PNG, it would be best to warn the user that they still have a lot of manual work to do on the ocean anyway. Particularly since it's still the responsibility of the map-editor to set every single other element (eg. Fungus, Rainforest, Rockiness, Moisture (?)) anyway. It would be very useful to feed the tool raw real-world map data, though (as much as that would also eat up astronomical amounts of RAM... I end up running out of RAM attempting to generate the greyscale PNG's alone...).

We can discuss the whole Charem thing privately, but I should be able to get you into easy contact with him, if necessary.
Title: Re: Generating maps based off PNG heightmaps?
Post by: Kilkakon on September 19, 2012, 06:59:16 AM
Perhaps one method of doing the heightmap is to make a coloured PNG, so red = % of rockiness, green = elevation, blue = rainfall? Probably a bit harder for a program to generate out of the box, but still could work? :)
Title: Re: Generating maps based off PNG heightmaps?
Post by: Flygon on September 19, 2012, 09:17:34 AM
I think, for now, we should just focus on elevation. I'm probably not the best geologist to poke about this. I'd be more concerned about oceanic depth than the rockiness and rainfall, regardless.
Title: Re: Generating maps based off PNG heightmaps?
Post by: Kilkakon on September 19, 2012, 09:25:35 AM
Okay sure. :) Do we know of any map format spec for us to look at?
Title: Re: Generating maps based off PNG heightmaps?
Post by: Flygon on September 19, 2012, 09:44:12 AM
Probably best to look at the OpenTTD greyscale heightmap (http://wiki.openttd.org/Heightmap) format. We should probably bring this to an instant messenger, it's easier to explain that there. As much as it deprives me of my forum based energy credits. I don't want to stink up the place with me struggling to explain the greyscale lightmap format.

I should stress that any heightmap fed to the tool should be exceptionally larger than the map itself being generated (for example, a 2048*2048 heightmap of Australia would be used to generate a 256*256 or 512*512 SMACX map), for the sake of very smooth altitude transitions. For how the intensity of the 'pixel' of  the heightmap should be converted to altitude... I say make it user settable. Nothing wrong with having unrealistically high altitudes on a large map, it adds to the potential fun, afterall. ;)

My personal default, though? FF high on the greyscale map becomes 3990m on SMACX.
Title: Re: Generating maps based off PNG heightmaps?
Post by: Kilkakon on September 19, 2012, 10:00:16 AM
Yeah I'd agree, wouldn't want to break the game with crazy height levels.

I have MSN and Skype, which would you prefer? PM me your details and we can chat. :D
Title: Re: Generating maps based off PNG heightmaps?
Post by: sisko on October 23, 2012, 07:12:41 AM
@Flygon: just a heads-up: https://www.tt-forums.net/viewtopic.php?f=60&t=63043 (https://www.tt-forums.net/viewtopic.php?f=60&t=63043)
Title: Re: Generating maps based off PNG heightmaps?
Post by: Flygon on October 26, 2012, 03:26:30 AM
@Flygon: just a heads-up: https://www.tt-forums.net/viewtopic.php?f=60&t=63043 (https://www.tt-forums.net/viewtopic.php?f=60&t=63043)
Gotta love how cyclic this can be. :D
Title: Re: Generating maps based off PNG heightmaps?
Post by: Kilkakon on October 27, 2012, 06:27:38 AM
Haha very funny how that went full circle. XD

Still, it would be great to have this working properly, a nice heightmap converter. Breaking the map format is really all that needs to happen.
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 4: index+Modifications.english (default), TopicRating/.english (default), PortaMx/PortaMx.english (default), OharaYTEmbed.english (default).
Style sheets: 0: .
Files included: 31 - 840KB. (show)
Queries used: 15.

[Show Queries]