Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Cubic Mesh Simplification Algorithms?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 chrisprij   Members   -  Reputation: 156

Like
0Likes
Like

Posted 08 July 2013 - 05:32 PM

Hey!! So I've been working on a voxel-mesh engine and it's turning out great (turns voxels into a cubic mesh for rendering, like Minecraft). I started with rendering chunks one block at a time, and then I switched to rendering each chunk as a mesh, only rendering the "shell" or outside of the mesh. The problem I'm having now is this:

 

The mesh is made up of one material. Clearly adjacent quads/squares (voxel faces) on the mesh, being made of the same material, should be able to be combined into a rectangle, therefore reducing the triangle and vertex count. How can I do this?

 

I've found a few sources online, like this and this, but I'm not understanding it, for some reason. Well...I get the idea, but I have no idea how to implement it. 

 

As for my Mesh class, I have the following data stored:

 

-a Vertex array

-a VertexNormal array

-a vertexColor array (materials are colors, not textures in my game).

-an triangleIndices array (for rendering).

-a quadIndices array (for simplification).

 

and I can add and remove from these as I need to, using the proper notation and algorithms (dont remove a vertex without removing triangles with that vertex, etc.).

 

Is there something else I'd need to add to my data storage for meshes? Any idea of where to start algorithm-wise for triangle/quad reduction? As chunks reach the top of the terrain (where the chunk will have air and blocks, not just blocks), I have trouble creating a working algorithm for storing the quadIndices in a way that I can simplify the mesh easily...

 

Help please! I feel like I could be close, but I feel more lost than ever right now :/

 

--CP



Sponsor:

#2 rnlf   Members   -  Reputation: 1270

Like
0Likes
Like

Posted 09 July 2013 - 02:54 AM

I'm not sure if you will really gain something by combining some of your quads into larger rectangles. One problem I see is that you'll have differently sized faces share a common edge. Like if you have one large 2x1 quad on row 1 and two small 1x1 quads on row 2: Your 2 quads on row 2 will have a vertex on one edge of the quad in row 1, which is not connected to row 1. I believe imprecisions and rounding errors might cause some trouble like small gaps an this point.

 

Also, computing the bigger quads and updating your index buffer may probably take more time than just rendering each quad of the shell.

 

Of course you will only know after trying and profiling it. To get your computations reasonably fast, you might want to store the edges of your mesh for reverse lookup. You each edge might be represented by a pair of references to the quads it connects. Computing adjacent quads is then just a matter of going throw all edges of a quad and check whether the quad on the other side is parallel to the one you currently process. First maximize it in one direction of the quad's plane, then the other.

 

This won't give you the optimal result in each case (like there may be a better subdivision for a large, irregular patch than this algorithm produces), but it should be fairly fast.


my blog (German)





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS