Skip to content

Commit

Permalink
Port to last version of RenderDoc, Chrome and Blender
Browse files Browse the repository at this point in the history
RenderDoc 1.6 (some API changes)
Chrome 80.0 Now using a different set of flags, using D3D11 API rather
than OpenGL.
Blender 2.82 Update RenderDoc binaries
  • Loading branch information
Elie Michel committed Feb 17, 2020
1 parent 8948ddb commit 3261fa2
Show file tree
Hide file tree
Showing 13 changed files with 205 additions and 56 deletions.
61 changes: 48 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*If this helps you save time or money for your job, please condier supporting the work involved in here ;)* [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=DNEEF8GDX2EV6&currency_code=EUR&source=url)

**News** (from Feb 17, 2020) A new version is available that should make the whole process easier and work on more hardware. It now uses the last version of RenderDoc (1.6), the last version of Chrome (80) and the last version of Blender (2.82). This is quite a change and if you notice any regression (like it used to work and now it does not) please report!

Maps Models Importer
====================

Expand All @@ -10,39 +12,54 @@ The `blender` directory contains the source code of the Blender add-on importing

![Screenshot of blender addon in action](doc/screenshot.png)

**NB** This is an add-on for Blender 2.80 and above, which you can download from [here](https://builder.blender.org/download/).

Installation
------------

Download a [release](https://github.com/eliemichel/MapsModelsImporter/releases) or make a zip of `blender/MapsModelsImporter/`. In Blender, go to `Edit > Preferences`, `Add-on`, `Install`, then browse to the zip file.
Download a [release](https://github.com/eliemichel/MapsModelsImporter/releases) or make a zip of `blender/MapsModelsImporter/`. In Blender 2.82, go to `Edit > Preferences`, `Add-on`, `Install`, then browse to the zip file.

**/!\ Do not use the "Download as zip" button of GitHub, make sure you use a release zip instead.**

Install [RenderDoc](https://renderdoc.org/builds). It [has been reported](https://github.com/eliemichel/MapsModelsImporter/issues/2) not working with the very last version. Try the portable version of RenderDoc 1.2 or RenderDoc 1.1.
Install [RenderDoc](https://renderdoc.org/builds) **version 1.6**.

NB: If you are using an older release (v0.1.x and before), you must use the portable version of RenderDoc 1.2 or RenderDoc 1.1. This is no longer the case since v0.2.0 of this add-on.

Usage
-----

You can follow instruction from the walkthrough video: https://youtu.be/X6Q7dbtXVZQ Alternatively, check out the following steps:

1. Start RenderDoc, and `File > Inject into process`;

2. Start chrome or chromium using specific flags: `chrome.exe --disable-gpu-sandbox --gpu-startup-dialog --use-angle=gl`. Do NOT press Ok on the dialog box yet;
2. Start terminal (Win+R, "cmd") and run (adapt the second line to the location of your Chrome installation):

```
set RENDERDOC_HOOK_EGL=0
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-gpu-sandbox --gpu-startup-dialog
```

3. In RenderDoc, search for the chrome process and inject into it;
3. Do NOT press Ok on the dialog box yet;

4. Press OK in the chrome dialog;
4. In RenderDoc, search for the chrome process and inject into it;

5. Go to Google Maps (not Google Earth!) in satellite view, and take a capture using `Print Screen` **while moving** in the viewport;
5. Press OK in the chrome dialog;

6. In RenderDoc, save the capture as an rdc file
6. Go to Google Maps (not Google Earth!) in satellite view, and take a capture using `Print Screen` **while moving** in the viewport;

7. In Blender, go to `File > Import > Google Maps Capture` an choose your capture file.
7. In RenderDoc, save the capture as an rdc file

If you feel lost, I made a quick walkthrough of the addon: https://youtu.be/X6Q7dbtXVZQ Useful information can be found in the comment of the video, as well as on [the support thread on blenderartists](https://blenderartists.org/t/google-maps-models-importer/1153561).
8. In Blender, go to `File > Import > Google Maps Capture` an choose your capture file.

For step 2. you can create a link to Chrome rather than usig the cmd, and put as target (again, adapt the path to `chrome.exe` to your installation):

```
C:\Windows\System32\cmd.exe /c "SET RENDERDOC_HOOK_EGL=0 && START "" ^"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe^" --disable-gpu-sandbox --gpu-startup-dialog"
```

Troubleshooting
---------------

Useful information can be found in the comment of the video, as well as on [the support thread on blenderartists](https://blenderartists.org/t/google-maps-models-importer/1153561).

### Linux

Unfortunately, the *inject into process* functionality of RenderDoc is not supported on linux. You can still import existing captures on linux, though.
Expand All @@ -55,7 +72,25 @@ By default, the addon limits to 200 blocks, but if you feel ready to let your Bl

### I don't want to uninstall Google Chrome...

Check this trick out: https://github.com/eliemichel/MapsModelsImporter/issues/15
Since version v0.2.0 of this add-on, it is no longer needed to install an old version of Chrome.

With older versions (depreciated) of this add-on, you have to use a specific version of Chrome. Check this trick out to install it alongside your current version: https://github.com/eliemichel/MapsModelsImporter/issues/15

### There is no option for 3D in Google Maps

Try appending `?force=webgl` at the end of the google maps URL.

### API: OpenGL (Not Presenting)

This was a common issue with versions of this add-on prior to v0.2.0. Update to the latest version of this add-on, then make sure you remove the `--use-angle=gl` option from the chrome shortcut.

### Chrome is showing a warning about an unsupported feature

If this is about the `--disable-gpu-sandbox` flag, it is just a warning, it should not be a problem.

### Chrome window is all plain black

Try to set and unset the fullscreen mode using F11.

Disclaimer
----------
Expand All @@ -68,7 +103,7 @@ Do not use this for any commercial nor redistribution purpose. Actually, the use
Help Wanted
-----------

This repository does not provide the required RenderDoc binaries for linux nor for OSX. If you have such a system, build RenderDoc against Python 3.7.0 (the minor version matters) to be compatible with the version of Blender's Python distribution.
This repository does not provide the required RenderDoc binaries for linux nor for OSX. If you have such a system, build RenderDoc against Python 3.7.4 (the minor version matters) to be compatible with the version of Blender's Python distribution.

Other links
-----------
Expand Down
94 changes: 92 additions & 2 deletions blender/MapsModelsImporter/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
*If this helps you save time or money for your job, please condier supporting the work involved in here ;)* [![Donate](https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=DNEEF8GDX2EV6&currency_code=EUR&source=url)

**News** (from Feb 17, 2020) A new version is available that should make the whole process easier and work on more hardware. It now uses the last version of RenderDoc (1.6), the last version of Chrome (80) and the last version of Blender (2.82). This is quite a change and if you notice any regression (like it used to work and now it does not) please report!

Maps Models Importer
====================

Expand All @@ -8,16 +12,102 @@ The `blender` directory contains the source code of the Blender add-on importing

![Screenshot of blender addon in action](doc/screenshot.png)

Installation
------------

Download a [release](https://github.com/eliemichel/MapsModelsImporter/releases) or make a zip of `blender/MapsModelsImporter/`. In Blender 2.82, go to `Edit > Preferences`, `Add-on`, `Install`, then browse to the zip file.

**/!\ Do not use the "Download as zip" button of GitHub, make sure you use a release zip instead.**

Install [RenderDoc](https://renderdoc.org/builds) **version 1.6**.

NB: If you are using an older release (v0.1.x and before), you must use the portable version of RenderDoc 1.2 or RenderDoc 1.1. This is no longer the case since v0.2.0 of this add-on.

Usage
-----

You can follow instruction from the walkthrough video: https://youtu.be/X6Q7dbtXVZQ Alternatively, check out the following steps:

1. Start RenderDoc, and `File > Inject into process`;

2. Start terminal (Win+R, "cmd") and run (adapt the second line to the location of your Chrome installation):

```
set RENDERDOC_HOOK_EGL=0
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --disable-gpu-sandbox --gpu-startup-dialog
```

3. Do NOT press Ok on the dialog box yet;

4. In RenderDoc, search for the chrome process and inject into it;

5. Press OK in the chrome dialog;

6. Go to Google Maps (not Google Earth!) in satellite view, and take a capture using `Print Screen` **while moving** in the viewport;

7. In RenderDoc, save the capture as an rdc file

8. In Blender, go to `File > Import > Google Maps Capture` an choose your capture file.

For step 2. you can create a link to Chrome rather than usig the cmd, and put as target (again, adapt the path to `chrome.exe` to your installation):

```
C:\Windows\System32\cmd.exe /c "SET RENDERDOC_HOOK_EGL=0 && START "" ^"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe^" --disable-gpu-sandbox --gpu-startup-dialog"
```

Troubleshooting
---------------

Useful information can be found in the comment of the video, as well as on [the support thread on blenderartists](https://blenderartists.org/t/google-maps-models-importer/1153561).

### Linux

Unfortunately, the *inject into process* functionality of RenderDoc is not supported on linux.

### Missing blocks

![Importer settings](doc/settings.png)

By default, the addon limits to 200 blocks, but if you feel ready to let your Blender hang for a moment, you can increase it.

### I don't want to uninstall Google Chrome...

Since version v0.2.0 of this add-on, it is no longer needed to install an old version of Chrome.

With older versions (depreciated) of this add-on, you have to use a specific version of Chrome. Check this trick out to install it alongside your current version: https://github.com/eliemichel/MapsModelsImporter/issues/15

### There is no option for 3D in Google Maps

Try appending `?force=webgl` at the end of the google maps URL.

### API: OpenGL (Not Presenting)

This was a common issue with versions of this add-on prior to v0.2.0. Update to the latest version of this add-on, then make sure you remove the `--use-angle=gl` option from the chrome shortcut.

### Chrome is showing a warning about an unsupported feature

If this is about the `--disable-gpu-sandbox` flag, it is just a warning, it should not be a problem.

### Chrome window is all plain black

Try to set and unset the fullscreen mode using F11.

Disclaimer
----------

This is a proof of concept showcasing how the 3D render process of Google Maps can be inspected. This is intended for educational purpose only. For a more in-depth analysis, see [](TODO)
This is a proof of concept showcasing how the 3D render process of Google Maps can be inspected. This is intended for educational purpose only. For a more in-depth analysis, see [Importing Actual 3D Models From Google Maps](https://blog.exppad.com/article/importing-actual-3d-models-from-google-maps).

Do not use this for any commercial nor redistribution purpose. Actually, the use of such tool might be allowed for private read-only use, as this is what happens when browsing Google Maps, but not beyond. I do not take responsibility for any use of this tool.


Help Wanted
-----------

This repository does not provide the required RenderDoc binaries for linux nor for OSX. If you have such a system, build RenderDoc against Python 3.7.0 (the minor version matters) to be compatible with the version of Blender's Python distribution.
This repository does not provide the required RenderDoc binaries for linux nor for OSX. If you have such a system, build RenderDoc against Python 3.7.4 (the minor version matters) to be compatible with the version of Blender's Python distribution.

Other links
-----------

To import map data in Blender, this open source addon is very handy: [domlysz/BlenderGIS](https://github.com/domlysz/BlenderGIS)

Here is another attempt at reverse-engineering Google data: [retroplasma/earth-reverse-engineering](https://github.com/retroplasma/earth-reverse-engineering)
4 changes: 2 additions & 2 deletions blender/MapsModelsImporter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
bl_info = {
"name": "Maps Models Importer",
"author": "Elie Michel",
"version": (0, 1, 3),
"blender": (2, 81, 0),
"version": (0, 2, 0),
"blender": (2, 82, 0),
"location": "File > Import > Google Maps Capture",
"description": "Import meshes from a Google Maps capture",
"warning": "",
Expand Down
Empty file.
Empty file.
Binary file modified blender/MapsModelsImporter/bin/win32/renderdoc.dll
Binary file not shown.
Binary file modified blender/MapsModelsImporter/bin/win32/renderdoc.pyd
Binary file not shown.
Binary file modified blender/MapsModelsImporter/bin/win64/renderdoc.dll
Binary file not shown.
Binary file modified blender/MapsModelsImporter/bin/win64/renderdoc.pyd
Binary file not shown.
36 changes: 25 additions & 11 deletions blender/MapsModelsImporter/google_maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

SCRIPT_PATH = os.path.join(os.path.dirname(os.path.realpath(__file__)), "google_maps_rd.py")

def captureToFiles(filepath, prefix):
def captureToFiles(filepath, prefix, max_blocks):
"""Extract binary files and textures from a RenderDoc capture file.
This spawns a standalone Python interpreter because renderdoc module cannot be loaded in embedded Python"""
blender_dir = os.path.dirname(sys.executable)
Expand All @@ -39,7 +39,7 @@ def captureToFiles(filepath, prefix):
os.environ["PYTHONPATH"] = os.environ.get("PYTHONPATH", "")
os.environ["PYTHONPATH"] += os.pathsep + os.path.abspath(getBinaryDir())
python = os.path.join(python_home, "bin", "python.exe" if sys.platform == "win32" else "python3.7m") # warning: hardcoded python version for non-windows might fail with Blender update
subprocess.run([python, SCRIPT_PATH, filepath, prefix])
subprocess.run([python, SCRIPT_PATH, filepath, prefix, str(max_blocks)])

# -----------------------------------------------------------------------------

Expand All @@ -55,19 +55,27 @@ def extractUniforms(constants, refMatrix):
"""Extract from constant buffer the model matrix and uv offset
The reference matrix is used to cancel the view part of teh modelview matrix
"""
uvOffsetScale = constants['$Globals']['webgl_fa7f624db8ab37d1']
mdata = constants['$Globals']['webgl_3c7b7f37a9bd4c1d']
globUniforms = constants['$Globals']
if '_w' in globUniforms:
[ou, ov, su, sv] = globUniforms['_w']
ov -= 1.0 / sv
sv = -sv
uvOffsetScale = [ou, ov, su, sv]
else:
uvOffsetScale = globUniforms['webgl_fa7f624db8ab37d1']
mdata = globUniforms['_s'] if '_s' in globUniforms else globUniforms['webgl_3c7b7f37a9bd4c1d']
matrix = Matrix([
mdata[0:4],
mdata[4:8],
mdata[8:12],
[0, 0, 0, 1],
])
mdata[12:16]
]).transposed()

if refMatrix is None:
# Rotate around Y because Google Maps uses X as up axis
refMatrix = Matrix.Rotation(-pi/2, 4, 'Y') @ matrix.inverted()
matrix = refMatrix @ matrix

matrix[0][3] *= .0039
matrix[1][3] *= .0039
matrix[2][3] *= .0039
Expand Down Expand Up @@ -133,15 +141,21 @@ def filesToBlender(context, prefix, max_blocks=200):
values = context.scene.maps_models_importer_ref_matrix
refMatrix = Matrix((values[0:4], values[4:8], values[8:12], values[12:16]))

if max_blocks <= 0:
# If no specific bound, max block is the number of .bin files in the directory
max_blocks = len([file for file in os.listdir(os.path.dirname(prefix)) if file.endswith(".bin")])

drawcallId = 0
while max_blocks <= 0 or drawcallId < max_blocks:
while drawcallId < max_blocks:
if not os.path.isfile("{}{:05d}-indices.bin".format(prefix, drawcallId)):
break
drawcallId += 1
continue

try:
indices, positions, uvs, img, constants = loadData(prefix, drawcallId)
except FileNotFoundError as err:
print("Skipping ({})".format(err))
drawcallId += 1
continue

uvOffsetScale, matrix, refMatrix = extractUniforms(constants, refMatrix)
Expand All @@ -154,7 +168,7 @@ def filesToBlender(context, prefix, max_blocks=200):

[ou, ov, su, sv] = uvOffsetScale
uvs = [ [ (floor(u * 65535.0 + 0.5) + ou) * su, (floor(v * 65535.0 + 0.5) + ov) * sv ] for u, v in uvs ]

if len(indices) == 0:
continue

Expand All @@ -177,5 +191,5 @@ def filesToBlender(context, prefix, max_blocks=200):

def importCapture(context, filepath, max_blocks, pref):
prefix = makeTmpDir(pref, filepath)
captureToFiles(filepath, prefix)
captureToFiles(filepath, prefix, max_blocks)
filesToBlender(context, prefix, max_blocks)
Loading

0 comments on commit 3261fa2

Please sign in to comment.