For my game, I have a tool that lets me quickly create map geometry. You can see a (albeit early version) demo of the tool here. The main problem with the tool is that even a semi-large map can EASILY amount to around thousands to even 10s of thousands of tiles. The easiest way to fix this, I found, was to use a script I found online to merge all of the tiles into one mesh at the start of runtime (this is because I want to still be able to edit my tilemap in the editor)

This works and has a noticable improvement to the performance (especially if post-processing is enabled) however I'm left with a mesh that has a bunch of triangles that just aren't needed. You can see an image of the mesh here. The problem with this is that if I want to do any kind of point lights with shadows (baked lighting isn't possible, really, due to the interactivity of my game since you can turn lights on/off and I have a weird day/night system that is split into multiple periods of the day and only changes after a mission/event) would mean I'm rendering that mesh again from each point lights POV (and I need a LOT of point lights). I can't really just not use shadows since it causes very noticable light bleeding at walls.

I've tried to find some sort of algorithm to simplify the mesh and I came across a script that seems to do exactly what I want, but I couldn't get it to do anything except cause my mesh to become completely black with seemingly no change in mesh topology. Here's the script by the way

I've also found an algorithm called Greedy Meshing which seems to also do what I want, but seems to be meant for voxel based worlds like minecraft and I'm not sure how to implement it in my case since my tiles aren't voxels.

I've been trying to find other algorithms but the various game dev servers on discord can't seem to help me. Does anyone know how I can solve this problem? I'm not really smart enough to come up with my own algorithm/system to simplify the mesh.

  • \$\begingroup\$ The algorithm must limit the aggregation process to polygons all having the same material and it must apply this material to the resulting polygons. Probably the script is simply ignoring the material and creates polygons with no material set. This would explain the black mesh. \$\endgroup\$ Jul 27, 2020 at 16:01
  • \$\begingroup\$ I don't think so, since a mesh with no attached materials is always pink for me. \$\endgroup\$ Jul 27, 2020 at 17:22
  • \$\begingroup\$ There's a great open source tool that can allow you to do this, and a lot more (vertex cache, vertex fetch, overdraw, etc!): github.com/zeux/meshoptimizer I've used it in a few personal projects, and it's fast, and quite straightforward ! \$\endgroup\$
    – acohade
    Oct 22, 2020 at 7:20
  • \$\begingroup\$ This is a Unity project. I don't think it'll be worth my time creating C# bindings for that nor trying to understand and translate the algorithms and porting them over to C# \$\endgroup\$ Nov 14, 2020 at 22:28

1 Answer 1


I have solved this for the most part, atleast for floor tiles.

I was able to get the script, that I spoke about in the OP that didn't work, working and was able to get it to simplify the floor tile mesh (wall simplification doesn't work yet, sadly.)

Here's an image of the tilemap in the editor and the tilemap at runtime


  • Tiles are first merged using Unity's MeshCombiner utility
  • Then the mesh simplification classes 'Weld' function is used to remove any duplicate vertices
  • Then the mesh simplification classes 'Simplify' function is used to simplify the mesh

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .