AWS Terrain Blender Add-on
Mon 25 April 2022I started looking into Blender add-ons this weekend (tutorial). On the face of it, it's pretty easy to create an installable add-on: it can be as simple as a *.py file, which builds UI components (e.g. panels, menus, etc.) and executes code with Operators.
I quickly found that passing values between UI components and contexts was somewhat difficult.
Hot take: making even the simplest UI with properties in Blender is unnecessarily complex
— Darren Wiens (@dkwiens) April 24, 2022
The trick seems to be to manage values in a more global sense through a PropertyGroup, which is fine, though feels unwieldy to me.
I made an example add-on here, which:
- creates a series of panels in the Tools tab of the 3D View
- accepts either geographic coordinates or tile coordinates
- fetches the corresponding AWS Terrain tile
- styles the tile as an ImageTexture in a Principled BSDF Material
- leverages elevation data through a Displace modifier
- displays the styled tile in the 3D View
To use, you must include morecantile in Blender's environment1. Then, download the gist and import to Blender through Preferences -> Add-ons -> Install...
The result is like this:
Carving away at an AWS Terrain tiles #b3d addon 🏔️ pic.twitter.com/A44ELwALwV
— Darren Wiens (@dkwiens) April 25, 2022
That's it. Get in touch with me on Twitter if you want to know more!
1: It can be tricky to install Python modules into the Blender environment. I followed a YouTube tutorial that I cannot find at the moment, but in short I created a conda env and symlinked it to the Blender environment.