Heightmap mesh optimization

Discuss about anything related to the Irrlicht Engine, or read announcements about any significant features or usage changes.
Post Reply
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Heightmap mesh optimization

Post by hendu »

https://sourceforge.net/tracker/?func=d ... tid=540678

This patch adds a new algorithm for mesh optimization. It's tuned for heightmaps, tiles in particular.

How it differs from the usual ones (such as the many ones in the irrExt repo):
- it is intended to be lossless
- it takes extra care around the mesh borders

These qualities let it be run on just about any static mesh. The main use for me is heightmap mesh tiles - if there are planar areas, this saves triangles and verts. The other common use is bad 3d art; you know what I'm talking about, a straight wall that has 60 tris when it should have 2.

The latter use case is somewhat hampered by the border code, but of course one should be teaching the artists, not post-processing their work ;)

Heightmap tile before - after:
Image
Image

Note how the borders don't change. It still tiles seamlessly without T-junctions.

Example when run on a mesh, too tesselated cube:
Image
Image

In this case, you can see how it's lossless, but not as good as it could be. There are two parts to this, the mentioned border limit, and the fact the algorithm is pass-based - it does not run until stabilization. If you need the finest models, you should run it 4-5 times.

For Minecraft-style worlds, having the cube like above, avoiding T-junctions, would still be desirable of course. ;)

PS: I do think the irrext simplification methods should be merged. They're self-sufficient and useful for lossy LOD.
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Heightmap mesh optimization

Post by hendu »

It runs in linear time (O(n) on vertex count), and can handle very complex meshes.

The example cube stabilizes after 2 passes:
Before: 96 verts 324 ind
p1: 74 verts 192 ind
p2: 72 verts 180 ind
p3: 72 verts 180 ind

It successfully cut 45% of the indices and 25% of the vertices in this model. The time to do the first pass wass 370 usec.


It should be noted that my weld cleanup patch is required to see the full potential - without it, irrlicht's welding does not remove degenerate tris, so the speedup is not as good as with it. The HW can drop degenerate tris early, but the best case is to not send them.
Post Reply