Heightmap-based displacement with 90-degree corners I'd like to generate simple rectangular geometry based on a heightmap such that all corners of the resulting mesh have an angle of 90 degrees and the overall mesh topology is &quot;clean&quot;.
For example, given this 16x16 heightmap (enlarged for clarity):

I'd like to generate a mesh that looks like this:

Here's what I've tried:

Create a grid with 100 subdivisions along both the X and Y axes and a side length of 16 units
Add a Displace modifier to it

Set Coordinates to UV
Set Strength to 16.0
Set Midlevel to 0.0


Set the texture of the Displace modifier to the 16x16 heightmap image

In the texture settings, under Sampling, uncheck Interpolation


Apply the Displace modifier
Enter edit mode
Perform a Limited Dissolve using a small angle (e.g., 1 degree; must be greater than 0 or no edges are dissolved)

That process yields this result:

This is close to what I want, but the topology is poor; in particular, the long, thin, triangular faces at corners and intersections are undesirable. I've tried merging vertices by distance and performing some of the clean-up operations, but doing so only degraded the topology further.
Is there a better approach that would obtain the desired result? Any suggestions would be appreciated, including plugins.
Here's the actual 16x16 heightmap for reference:
Here’s one way to do it mostly non-destructively:

Start with a plane.


In edit mode, use CtrlE ▸ Subdivide to subdivide the plane into a 16×16 grid.


Add a Bevel modifier with Limit Method ▸ None, Amount ▸ 0.0001 m, and Segments ▸ 1. This creates some additional geometry so displacements are sharp.


Add a Displace modifier using your height map texture. Under the texture options, make sure to disable the Sampling ▸ Interpolation option, so the boundaries of the height map will be sharp. This produces a nice, sharp result:


To clean up the geometry, add a Weld modifier followed by a Decimate modifier set to the Planar mode. This will delete most of the redundant edges, leaving a clean, low-poly mesh: