122 lines
8.0 KiB
Plaintext
122 lines
8.0 KiB
Plaintext
|
[section]Orthographic[/section]
|
||
|
|
||
|
A utility to generate photorealistic satellite imagery of any location in the world. Aimed to be an alternative for ortho photos in flight simulators, such as X-Plane or Microsoft Flight Simulator. Written in Python.
|
||
|
|
||
|
While tools like Ortho4XP or AutoOrtho can provide next-level realism into X-Plane, the idea still falls short when it hits photos that were stitched together. In one or many ortho photos, you will see parts of the specific area of which the photo was not taken at the same time as another part, resulting in what is known as discoloration. Sometimes you will also find clouds in the photos, or remnants of buildings or attractions which show perspective distortion. This is a huge immersion-breaker for me and many others. A problem I wanted to tackle for my flight simulator - Orthographic may just be the solution that does away with all issues when it comes to ortho photos in flight simulators.
|
||
|
|
||
|
Currently, three zoom levels are implemented, which are practically all cases suited well enough for the purpose of flight simulation: 16, 17, 18. I used zoom level 16 for areas I fly over, and 18 for areas close to an airport.
|
||
|
|
||
|
[section]Wait, just what are ortho photos?[/section]
|
||
|
|
||
|
Aerial photos taken with a satellite, of varying resolution, altitude, and detail. When you switch to satellite in Google or Bing Maps - what you see is a collage of ortho photos, depending on how close or far away you are zoomed in.
|
||
|
|
||
|
[section]What it is[/section]
|
||
|
|
||
|
As outlined, it is a tool that can generate, or rather - approximate, photo-realistic ortho photos. It does so by using a number of sophisticated mechanisms to generate these. These photos are then used as textures for the specific area the photo is made for - specifically a latitude and longitude coordinate.
|
||
|
|
||
|
[section]What it is not[/section]
|
||
|
|
||
|
It is obviously not a full replacement for the real thing - satellites provide photos of how the world really is. Orthographic can only approximate the looks, and it tries to do this as best as it can using the data it knows about the specific latitude and longitude... but do not expect a complete 1:1 match of the real world with fixed coloration. It is also not meant to compete with mapping services or tools - it is merely a collection of scripts working together to offer a close approximation of how a satellite photo would look like.
|
||
|
|
||
|
[section]How does this work?[/section]
|
||
|
|
||
|
It boils down into these steps:
|
||
|
|
||
|
- Acquire OSM data for the tile from my API
|
||
|
- Construct masks from that data, for a number of layers, from top to bottom
|
||
|
- Covert each mask layer to a photo-realistic layer
|
||
|
- Merge (blend) all layers from bottom to top
|
||
|
|
||
|
Orthographic creates zoom level 18 tiles for everything it encounters - but at the end, once all orthos are generated, zoom level 16 photos will be the final product as this is in almost all cases sufficient to fly in many altitudes.
|
||
|
|
||
|
However, around airports, it will keep the original zoom level 18 tiles so that you have more detail when you fly into, and away from, airports.
|
||
|
|
||
|
This is achieved by "memorizing" all airports with ICAO codes it encounters along its journey, then determining which ortho tiles to keep at zoom level 18.
|
||
|
|
||
|
|
||
|
[section]Important things to note[/section]
|
||
|
|
||
|
Orthographic does its very best to approximate good-looking ortho photos, as if they were taken by a satellite. However it is what it is: an approximation - it cannot replace or even get close to the actual, real world. I have tried my very best to bring in some variety, and make it so that every part generated does not repeat or look the same - like it is the case with other ortho packages I have tried, apart from Ortho4XP / AutoOrtho.
|
||
|
|
||
|
It is, at the end of the day, for a flight simulator. Orthographic can strike the right balance between accuracy of the part of the world you fly in, and looks.
|
||
|
|
||
|
|
||
|
[section]Where it excels[/section]
|
||
|
|
||
|
It does a really good job at generating good-looking photo tiles, and knows how to correct Mercator distortion to render these tiles.
|
||
|
|
||
|
It also does a good job at making sure the tiles are seamless, and knows where a tile needs to be seamless, while at the same time, it also knows when it can pick something and be creative.
|
||
|
|
||
|
During development it also learned how to make a few things look more realistic - namely (hopefully good enough, or believable) shadows for certain elements.
|
||
|
|
||
|
|
||
|
[section]Where it falls short[/section]
|
||
|
|
||
|
Of course, an algorithm of this magnitude can only go so far. Also, this is a one-man project - which means I do not have the monetary resources to make this the ultimate ortho photo solution that works without a satellite... but still, I believe to have done a fairly good job - that is for you to decide. Our planet is vast and so is the data available for it - over time Orthographic will learn more and more how to make use of that data.
|
||
|
|
||
|
In other words, it fails to generate parts of the world where there is no OSM data available. At this time, Orthographic gets creative to fill in the gaps.
|
||
|
|
||
|
At this time, it also falls short in generating the 3D geometry for a tile. It is specialised to generate ortho photos - or in other words, textures for existing geometry.
|
||
|
|
||
|
Buildings are usually generalized and show up with the same pattern. I need to work on that.
|
||
|
|
||
|
Apart from that I am aware that the code is most likely not the best and can be optimized. It is my first serious Python project.
|
||
|
|
||
|
|
||
|
[section]Requirements[/section]
|
||
|
|
||
|
- Current Python version
|
||
|
- Pillow for Python
|
||
|
|
||
|
[section]Configuration[/section]
|
||
|
|
||
|
- Open the file defines.py
|
||
|
- Change mstr_datafolder to where you want the data of Orthographic to be stored and placed
|
||
|
- Change mstr_airport_radius to an amount in kilometers. Areas around airports with ICAO code will get aerials with zoom level 18
|
||
|
|
||
|
In this file you can also define how large you want the final products to be - you can choose between 4k resolution (2048px) or 16k resolution (4096). The choice you make here should be based on 1) how much detail you want, and 2) how much VRAM your GPU has. The larger a texture, the more VRAM is needed, and the more processing is required by the GPU. I personally go with 2048, as I have a RTX2060, so my VRAM is limited. When at altitudes of 10,000 feet and above, you will most definitely not notice the difference between 4096 and 2048.
|
||
|
|
||
|
Change the mstr_photores variable to 4096 if you want the maximum possible.
|
||
|
|
||
|
Just a note: 4096 also uses 4x more hard drive space. 4k uses about 2MB per image, where as 16k uses about 8-10MB per image. This may not seem much for one image, but keep in mind we are talking about quite a considerable number of images. To get an idea - if you have it, look into any folder of an Ortho4XP tile in your X-Plane folder, and check the size of the "textures" folder.
|
||
|
|
||
|
|
||
|
[section]Running![/section]
|
||
|
|
||
|
Very simple.
|
||
|
|
||
|
[codebox]python main.py LATITUDE LONGITUDE[/codebox]
|
||
|
|
||
|
So for example
|
||
|
|
||
|
[codebox]python main.py 51 7[codebox]
|
||
|
|
||
|
This does everything for you.
|
||
|
|
||
|
ATTENTION! This process will take a considerable amount of time due to the work being involved. Please keep this in mind, especially if you seek to do this for an entire country.
|
||
|
|
||
|
I am considering hosting the finished tiles on my server, so that you only need to download the finished photos / tile packs.
|
||
|
|
||
|
|
||
|
[section]Examples[/section]
|
||
|
|
||
|
Dortmund, Germany
|
||
|
|
||
|
[REAL WORLD]
|
||
|
|
||
|
[RESULT]
|
||
|
|
||
|
|
||
|
Leverkusen, Germany
|
||
|
|
||
|
[REAL WORLD]
|
||
|
|
||
|
[RESULT]
|
||
|
|
||
|
|
||
|
[section]Improving the code[/section]
|
||
|
|
||
|
As I have hosted this on my private but publicly accessible gitweb (which is the same tool kernel.org uses btw), it should be clear that I am making the code available to everyone. Of course, you are free to improve (I am sure the code needs some optimisation). If you changed or improved something, and you publish it (no matter where), you MUST adhere to the license this software ships with, which is OSL 3.0.
|
||
|
|
||
|
As it is hosted on my private gitweb, and not in a public instance like GitHub, I need to be very careful and clear about this. In short it means, also legally, that you cannot download the current snapshot, post the content somewhere else, and claim you made it. Respect the time, work and energy I have invested into this project :)
|