Skip to content

gojushin/EnvironmentLodTools

Repository files navigation

Logo


Blender Plugins Standalone

Environment LOD Tools

Environment LOD Tools are a collection of plugins for Blender (v. 4.2.0 and above). The plugins are designed to help with the creation of environment levels of detail (LODs) for terrestrial photogrammetry models. (Models of Landscapes, Cities, and other "flat" structures).

The tools are split into several single plugins, that can be used independently of each other. There is also a combined plugin that can load a model from the file system and generate LODs for it, without actively rendering it to the viewport. This is essential for source files that are too massive to display in the viewport.

Blender Plugins are available for Windows, Linux and Mac (experimental).

Note

For Windows there is also a self-contained, zero-config GUI application available.

LOD Example logo

Features

  • Cleanup: Cleans/Preprocesses the mesh for use in the LOD pipeline. All mesh operations are done using the BMesh framework to ensure performance. Pyfqmr is used for mesh reduction.

  • Mesh Slicer: Cuts a mesh into a user-defined amount of square slices. (This reimplements Blenders Bisect logic in a way that does not require to duplicate the mesh in order to keep both half's)

  • LOD Pipeline: Generates the levels of detail (LODs) for all the selections using pyfqmr again. The LOD generation retains the borders of the highest LOD for flawless LOD transitions of individual modules.

  • XAtlas Unwrapper: Unwraps the model using the xatlas-python bindings. Utilizes multiprocessing to speed up the unwrapping of multiple meshes significantly.

  • Baker: Transfers the base color of a defined mesh onto one or multiple selected meshes. Blender is used as the baking framework.

GUI Example

Installation

GUI

EnvironmentLodTools can also be used with a "standalone" PySide6 based GUI. It exposes the exact same parameters, but uses a small C++ Launcher targeting an embedded Python install, with Blender as a module.

To use the GUI do the following:

  1. Download the enviro_gui[...].zip from the latest release.
  2. Run the contained .exe file.

Plugin

To install the plugins, follow these steps:

  1. Download the latest release from GitHub.
  2. In Blender, go to Edit -> Preferences -> Add-ons and click on the Install from lokal disk hidden in the submenu on the top right.
  3. Select the .zip file from the download folder.
  4. Enable the plugins by checking the plugins checkbox.
  5. Once installed, the plugins can be accessed through the Tool and Tools panel.

Building

Using the provided scripts

  • Run build.sh using a applicable shell (i.e. GitShell, MinGW64, MSYS2, etc...)

Note

build.sh takes two additional optional arguments:

--blender (which lets you define the fielpath to the blender installation to use for plugin building.)

--python-version (which lets you define the python version for building. i.e.: 3.11.9)

Building from scratch

  • Download the correct wheels pyfqmr and xatlas for your correct platform and python version an place them in .plugin_src/wheels

  • Add the path(s) to the wheels to the blender manifest at .plugin_src/blender_manifest.toml

  • Ensure you have Blender installed.

  • Build the Plugin using Blenders build command:

    blender --command extension build

    See also: Blender Docs

  • Ensure the plugins name has the correct naming depending on your target platform:

    • Win: windows_x64.zip
    • OSX: macos_arm64.zip
    • Linux: linux_x64.zip
  • Download the desired embeddable python package.

  • Unpack it to .python_embed/, unless you change the path in the launcher.cpp.

  • Enable Site Support by either using Powershell or Bash. Do this by running one of the following commands inside the directory where there embedded python exectuable lives.

    -Command "(Get-Content python*._pth) -replace '^#import site', 'import site' | Set-Content python*._pth"

    or

    sed -i 's/^#import site/import site/' python*._pth
  • Install pip into the embeddable Python:

    • Download get-pip.py from here.
    • Navigate to the directory the embeddable python.exe is located, place the downloaded file here and run:
      python.exe get-pip.py
  • Using the embeddable Python Pip install the Blender as a module and PySide

    python.exe -m pip install bpy
    python.exe -m pip install PySide6
  • Build the launcher using CMake (We are using MinGW, but you can use any Compiler you please):

    cmake -G "MinGW Makefiles" ..
    cmake --build .
    
  • Ensure the folder structure looks as follows:

    πŸ“ root
    β”œβ”€β”€ πŸ“„ launcher.exe
    β”œβ”€β”€ πŸ“„ enviro_tools_gui.py
    β”œβ”€β”€ πŸ“„ styles.qss (optional)
    β”œβ”€β”€ πŸ“„ blender_plugin_windows_x64.zip
    β”œβ”€β”€ πŸ“ python_embed/
    β”‚   └── πŸ“„ ...
    └── πŸ“ plugin_src/
        └── πŸ“„ ...
    

Known Issues

The UI freezes once "Start" is pressed in the GUI

This behavior occurs because, in Python, two event loops cannot run concurrently in the same thread. This limitation stems from the environment in which the application is currently executed. I plan to address this in a future update by running the two event loops of PySide and Blender-as-a-module in separate threads and connecting them via IPC. Do not worry though, even if the GUI freezes, the processing will still take place.

Contributing

Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.

License

The code is licensed under the GPLv3 License.

Credits

This project was originally created by Nico Breycha (High Vision) for the Deine Stadt project.

3rd party libraries used in this project are licensed under their own licenses.

Older Versions

As of June 2025 I no longer support Blender Versions 4.1 and below. The latest release for these versions can be found here.

About

A Collection of Blender Plugins to aid with the LOD creation of terrestrial photogrammetry models.

Topics

Resources

License

Stars

Watchers

Forks