Help with procedural cave generation mesh

Hi, I’ve been following along with the Procedural Cave Generation tutorial by Sebastian Lague since it is almost exactly what I need. The change I needed to make to the example was that I wanted the generation to be cube-like instead of angled on all edges and walls. I was able to convert the top visual look to show the cubed edges that I was looking for.

The issue and part that I have been struggling to solve is when the walls are added.


While messing with the code I noticed that the mesh requires the triangles and seems to be why the shorter 1x1 walls have a triangle mesh added but the 2x2 walls are flat like I require. Although it seems like the longer straight walls result in a larger triangle shape like so

I think what I need to do is find the 2 vertices of just the straight walls and reuse one of them to create a ‘flat’ triangle. I just don’t know exactly how to do that.

I am wondering if there is a way to simply just expand the first mesh that was created so the walls aren’t even necessary since the mesh will be vertically stretched in a way. If there is a way to do that or if someone could help me solve the problem that would be amazing. I have been playing with the scripts and googling for the past couple days. This is the first time I have dealt with procedural generation and generating meshes from it so it is still a little confusing to me. Thanks to anyone who attempts to help me solve my issue.

I’m not sure how the cell grid is being stored, but you should be able to just traverse the thin edge between the verts and “drop walls down” from each flat side, without being worried about the diagonals.

I think also some of your objects have the triangles wound the wrong way: facing inwards. Use left hand rule for making the triangles. I enclosed a little project that sort of shows that left hand rule.

I would make a quick empty test scene and get handy with the basics of producing vertices and connect up your “sheet wall” going around the perimeter of the land crust, then go back and try and integrate it with the actual bigger procedural mesh project.

3172563–241703–MakeProceduralMesh.unitypackage (3.84 KB)