Jump to content
  • Advertisement
  • entries
    13
  • comments
    55
  • views
    20921

Mesher ~ another iteration

Sign in to follow this  
eppo

2501 views

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,

jsJLEb1.png?1

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.).

N5DPRWc.png?3

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:

1TzQbAC.png?4

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.

render009.jpg


render010.jpg


render011.jpg
Sign in to follow this  


6 Comments


Recommended Comments

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

Share this comment


Link to comment

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.

Share this comment


Link to comment

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.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!