As mentioned in #720, we want to convert the old SLP terrain files to a flat terrain texture. I've implemented a working prototype for that utilizing the dimetric projection algorithm from the openage modding repository. The resulting python script can be found here. It operates on the output of our current converter.
merge() puts the single tiles together into one giant tile. transform() projects the result from dimetric to the desired flat perspective. Here you see the output when converting 15006.slp.png.

Textures from SLPs will always have a ratio of 1:1 and a size of 481x481 (compared to 512x512 in HD).
If somebody want to implement a more efficient version of the script and integrate it into the converter, go ahead.
Since terrain textures in HD are 512x512 pixels, I suggest to generate flat terrain textures with the same resolution in the conversion step.
@mikadou We might not need to anymore, since we agreed on doing 3D terrain. The texture will be independent from the tiling and thus can just be painted on the terrain without the need to scale it.
@heinezen Thanks for confirming the consensus on 3d terrain. I fully agree with going in this direction.
My thought about the 512x512 textures was because a few years ago when I last experimented with OpenGL it was recommended to use textures with sizes power of two. Not sure if this is still relevant though.
For the usual on-GPU memory allocation algorithms I think it still is (because the malloc algorithms likely use 2^x bucket sizes). With today's huge memory sizes I think we should ignore this for now and look for optimizations later.
Just to save this link:
How to generate 3D terrain from e.g. Google Maps
https://www.youtube.com/watch?v=Bb0HnaYNUx4
Anyone is working on it ? I can try to do it.
@charliergi No, nobody working on it currently. You can do it if you want :)
It would be great if you could translate the code to cython (for extra speed) and integrate the script directly into the converter (openage/convert/ in the repo). You can therefore ignore the output logic from the script linked above and instead take a numpy.ndarry as input for the image data. The array is returned by our media conversion:
To output the image, you can use the Texture object in openage/convert/texture.py
If you want, you can also add the option for terrain merging to the singlefile converter:
https://github.com/SFTtech/openage/blob/master/openage/convert/singlefile.py
Thanks for the description. I'm not familiar with Cython but i'll do my best to convert it.
I also have a question for it :
The best way to test would be adding a terrain option to the singlefile converter. This would then directly output the resulting image if you implemented it.
You can use the normal terrain SLP files of AoC for testing. The conversion from SLP to numpy.ndarray is already implemented in slp.pyx. You would just have to add the additional step that merges the frames and transforms the pixels to a flat texture :)
Hello !
One simple question that comes to my mind when I try to implement it :
input_data should be an instance of SLP for terrains. The SLP object reads a .slp file on creation, that's why the init function in the Texture class can access its frames. SLP objects are created from passed files, for example in singlefile.py.
Hello!
I've learned a bit more about Cython this week. I've managed to understand the structure of the project and translate (pure Python for the moment) your script above, and changed some things as suggested :
First I created a new method in singlefile.py, that will read a SLP inside a DRS archive (I've only this game version so I can't test more recent versions) and save it as a PNG.
Then I call your translated script that will open and read this file, and make the transformations. For the moment, this script returns a PIL Image.
Now, as suggested, I would like to use the function determine_rgba_matrix() from the SLP.pyx in order to obtain the pixel numpy.ndarray of this PIL Image and output a Texture from it, but I don't know how to do it. I try to extract the pixel matrix from the PIL image but I don't find a way to do it. Maybe it's because I don't really understand concretly the format of these images.
I know that save a Texture and open it again is completly useless, but I haven't find another way to do it. When I will succeed to convert it properly, i'll optimize the code.
Am I in the good way ? Feel free to correct me :)
I suggest you create a PR or Draft for your code, so we can discuss it better. Talking about what you did without seeing it is otherwise a bit of guesswork :D
Now, as suggested, I would like to use the function determine_rgba_matrix() from the SLP.pyx in order to obtain the pixel numpy.ndarray of this PIL Image and output a Texture from it
You should not (and cannot) use the function on the final image. determine_rgba_matrix() does not handle normal RGBA image data, but the special SLP image data. More precisely, the method receives special SLP image data as input and outputs RGBA image data. Instead of outputting the texture first, you should implement the transformation before the final image gets created. Or rather after texture.py fetches the image data from the SLP object.