Jump to content


Posted Image

Recent Entries

- - - - -

Mesher ~ another iteration

isosurfaces contouring FEM
4: Adsense

Felt my meshing tool needed another rewrite; getting trickier though.

The idea behind the tool is to construct a mesh using smaller simpler building blocks; kind of like a purely additive CSG modeller. I started out with a Marching Cubes implementation, but I really wanted it to be able to capture sharp edges in the base geometry. Also the triangle quality of the generated meshes needed improving. I prefer to bake data as vertex maps whenever I can, but shading based on interpolation between per-vertex values on awkwardly shaped triangles can quickly give poor results.

Scene are built using standard non-self intersecting meshes as basic building blocks. The advantage of this is that I can use any existing modeller to set these scenes up while allowing for a lot less linear workflow. Blocks are modelled once and can then be instantiated/transformed multiple times into the scene.

The algorithm then starts out by turning the bounding box of the mesh into a set of connected tetrahedrons. From there it keeps sampling the background mesh and using that data to refine the tetrahedral grid until it resembles the original mesh. It ends up with a big blob of tetrahedrons with a single connected triangle manifold on the surface.

What's nice about tetrahedrons is that they're guaranteed to be convex objects, so you basically get a convex decomposition (for collision detection) for free. Though I do a quick merge-pass to see if individual tets can be clustered together to form larger convex chunks. A volumetric description of the mesh allows for more robust intersection testing, but I only really need to keep the outer "crust" of tetrahedrons around, so I discard the inner ones to save on memory,

Posted Image

Any vertex weight map applied to the base mesh is projected back onto the resulting triangle mesh. I use these as masks for textures and density maps for surface particle replication (foliage etc.).

Posted Image

Two Catmull-Rom curves projected as road uv-maps. Locally the vertex resolution needs to be uniform and high enough to capture the curvature of the road. The green weight map masks a grass texture while also modulating the alpha channel of the road:

Posted Image

And the final scene textured and baked in Modo. Modo allows you to set up a pre-shaded environment into which you can simply drop newly generated meshes to have them automatically have their materials etc. applied.

Posted Image

Posted Image

Posted Image

Apr 22 2014 08:41 AM

Wow. That's fricking awsome.

Apr 22 2014 01:47 PM

That looks pretty damn good bro.

Apr 22 2014 03:09 PM

I really like that! I'm jealous I can't make cool stuff like this :P Good thing to aspire towards i guess! :)

Apr 23 2014 05:50 AM

Very cool.


The larger triangles you can see on the surface of the sphere, are they created through the merge process while the smaller ones are more representative of the tet-grid resolution?


Would be interesting to see how different grid resolutions fair.


I think the algorithm is different from Marching Tetrahedra, but I wonder if they produce similar looking end results.

Apr 23 2014 02:32 PM

Thanks guys.


The Marching Cube type algorithms draw polygons in the grid by connecting vertices along the grid's edges. My algorithm iteratively alters the grid(-vertices) itself, so the triangles you see lie on the actual borders of grid cells.


The edge lengths of the original mesh are used to define whether cells in the grid need to be further subdivided, making the grid resolution locally adjust to the input mesh. Also only cells that overlap the iso-threshold are examined, leaving larger cells on the inside of the volume.

Note: GameDev.net moderates comments.