muumimorko / MSFS2020_CGLTools

23 stars 5 forks source link

Azure TIN/Photogrammetry/MTX file format #2

Open muumimorko opened 3 years ago

muumimorko commented 3 years ago

Figuring out TIN file format, being able to generate (and inject) TIN tiles to the game, would allow for arbitrarily high resolution.

TIN source for the game is https://kh.ssl.ak.tiles.virtualearth.net/tiles/mtx{quadkey}?g={genid}&tf=3dv3&n=z

Example files, suspecting they each contains a TIN mesh and bitmap texture at least. 02301231130300222 (https://kh.ssl.ak.tiles.virtualearth.net/tiles/mtx02301231130300222?g=9003&tf=3dv3&n=z) mtx02301231130300222.zip Texture resolution 1024x512 pixels

mtx0230123113030022.zip Texture resolution 512x1024 pixels

mtx023012311303002.zip Texture resolution 512x1024 pixels.

First 6 byte seems to be identical 04 28 B5 2F FD A0

Bavarello commented 3 years ago

"TIN source for the game is https://kh.ssl.ak.tiles.virtualearth.net/tiles/mtx{quadkey}?g={genid}&tf=3dv3&n=z"

Bad Request

muumimorko commented 3 years ago

Need to replace {quadkey} with valid quadkey (eg. '023012311303002') and {genid} with genid {eg. '9003'} like in example below it.

Bavarello commented 3 years ago

https://kh.ssl.ak.tiles.virtualearth.net/tiles/mtx{023012311303002}?g={9003}&tf=3dv3&n=z Bad Request

https://kh.ssl.ak.tiles.virtualearth.net/tiles/mtx02301231130300222}?g=9003}&tf=3dv3&n=z Bad Request

Directly accessing the Bing Maps tiles https://docs.microsoft.com/en-us/bingmaps/rest-services/directly-accessing-the-bing-maps-tiles "It should be noted that the tile URLs for Bing Maps change regularly and as such directly accessing tiles from a hardcoded URL is not allowed."

I thank you, for having opened a new horizon but it's all new and hard for me to follow ... but I don't give up I always accept new challenges.

mohitvashistha commented 3 years ago

I am also trying to understand this file format.

I use Maps app in Win10 with fiddler to get the URLs. Even though if you will crack the file format, you cannot store the tiles as per Microsoft's term of use (as per my understanding).

I think they have a collaboration with Cesium to get their 3D Tileset. Is this 3D tile format

muumimorko commented 3 years ago

Good point about not storing data, not intending to do that.

Another thing is that the game uses more advanced tls key exchange (ECDHE_RSA, IIRC), when actually retrieving tile data from Azure, which can not be "decrypted" (at least not as easily).

muumimorko commented 3 years ago

I think they have a collaboration with Cesium to get their 3D Tileset. Is this 3D tile format

If that is the the file format, specifically "b3dm", the mtx is compressed/encrypted container, as there is no structure in the mtx file.

There is a Unity Maps SDK from microsoft, it has a sample for using 3D data, maybe it could help fiquring the format out. https://github.com/microsoft/MapsSDK-Unity/

Another thing is that the game uses more advanced tls key exchange (ECDHE_RSA, IIRC), when actually retrieving tile data from Azure, which can not be "decrypted" (at least not as easily).

There is no need to break TLS, just directing traffic to middleman https server, via for example changing hosts-file, works.

kh.ssl.ak.tiles.virtualearth.net - Satellite imagery, Photogrammetry, Color correction data (Filter that makes everything green)
khstorelive.azureedge.net - CGLs
kh-k8s-prod-cdn.azureedge.net - Metar

Started a new repository for a "Proxy" server: https://github.com/muumimorko/MSFS2020_Proxy Example results of blocking color correction data and injecting texture tiles cut from aerial photographs. NoGreenComp

derekhe commented 3 years ago

@muumimorko There is a way to replace the bing map with google, find it out here: https://github.com/derekhe/msfs2020-google-map/blob/main/README.EN.md

seanisom commented 3 years ago

Hi @derekhe, great work on the proxy server. If I understand correctly, that is replacing the aerial (a/kha/cci) tiles and not the photogrammetry (mtx) tiles?

It would theoretically be possible to replace mtx tiles with google photogrammetry, assuming you could convert the coverage maps where the two data sets converge. I have the Bing mtx format(s) and the Google rocktree protobuf format is described here: https://github.com/retroplasma/earth-reverse-engineering

However, it would be expensive to perform the format conversion between the 3d formats at runtime, one might want to do this offline and only proxy mtx tiles from a local cache.

derekhe commented 3 years ago

@seanisom yes, that's aerial tiles, that would fix the China mainland's old image issue. I'd like to see if other things can be replaced, local cache is a good idea.

lucascavatoni commented 1 year ago

Hi @muumimorko,

You mentioned :

kh-k8s-prod-cdn.azureedge.net - Metar

I guess you were not referring to meteorological METARs, were you ? Anyway, it would be very interesting if we could block the METARs from being downloaded, to only have meteoblue weather data.

Cheers