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 "clean".
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: