No problem, take your time. It’s a lot to learn.
The problem with instanced static meshes is performance. I’ve yet to find a use for them myself other than just to visualize 3D grids quickly for debugging purposes of algorithms.
Need to get one thing out of the way, which I should have asked first. Is there a gameplay reason for the existence of tiles? Such as being able to replace a grass tile with a dirt tile? Otherwise I would forget about making all tiles a separate mesh entirely.
This is great, the grid is all we need.
This seems to be true for both the instanced and procedural mesh, but with the procedural mesh you would end up with only 2 meshes, one a grass plane, other a dirt road.
These don’t go well together. For a big terrain which makes your PC suffer, you would probably rather go with a more complex initial setup / calculations of which after completion of creating the landscape the PC will not suffer.
You can’t set a material per instance as far as I am aware, unless you use one instanced mesh component for grass and one for road.
If you wish to go the more initially complex route and really build a mesh from scratch, you most likely end up with a higher final performance but you have some learning to do.
Below is the first thing I come up with, first pancake is never the best but I have made similar systems before.
When you generate your 2D grid, say white == roads, then the center of every white tile represents a point on the grid. the size of the amount of units you want a tile to be, which could be 100cm a tile. On the image I have pulled them apart a bit so we can clearly see the corners of the squares we end up with.
The square corner points can be stored, then used as vertices to create a mesh with.
Optimally, the vertices you store would be shown in red:
A smart approach is possible to create only the square corners relevant for the mesh but that has to be thought through well to not run into exceptions. For now just store 4 corners per tile on the grid. Forgive me for my rough sketch:
A corner point can be stored on a map of key FIntPoint (XY Coordinate) to value FVector4 (4 corners of float values). A corner point can be retrieved by multiplying the grid position by the tile size (say X3X5 * 100 becomes X300Y500) and adding half of the tile size towards the corner points. When you collected all those red points it is done and ready for Delaunay. You can copypaste my delaunay implementation into your project and pass in the points, it will give you the triangles that optimally connect neighboring points over the entire path. That triangle data can be fed into the ProceduralMeshComponent as is.