I’m generating a map from existing game data using PlaneGeometry and move the positions up or down based on a height map. I’d like to optimize this geometry by merging the flat areas. The UVs must still “work” as they do now. Key terms I’ve distinguished are coplanar, as well as a dissolve method in blender. Any tips for a rather non mathematically inclined individual?
The idea appears sensible.
Let’s assume you arrive at a set of “flat” (or same height) polygons, likely non-convex ones, which I think is achievable. You’ll then have to decompose those into triangles again, because that’s the way three.js works. There will possibly be fewer triangles than what you started with. But I expect the savings to be considerably smaller than you seem to expect. Depending of course on the properties of your map relative to your height field.
You might save big, if your combination of map and height-field contains large rectangular chunks of flat terrain. You could replace each rectangular chunk with two triangles and keep their uv-coordinates.
It will be a trade-off whether dealing with the fringe flat parts surrounding those rectangle will be worth special treatment. Again, this is data dependent. and there is no general answer to your question.
In my particular case it will definitely be worth it as the terrain rendering is a gpu hog. I’m also lucky that the game is oriented around flat areas since that is the only buildable regions, with edges being elevation changes or sparse decorations, so combining the flat areas like you said would be great. All flat areas are guaranteed to have the same normals as well, facing up. I will see what I can come up with.