Lot of the same quad mesh - elegant unity free solution + rendering order bug?

Hello!

I have follows scene:

Grid is built from objects with quad mesh (transparent and same for all), color flats are built from objects with quad mesh too, but from one material for all (atlas). Cube is using the same material as color flats.
But it is too slow (low fps).

When I disable mesh renderer for grid objects, speed is fine:

I see one solution - make grid from big images, but it’s not so elegant, because if I want a part of grid with some parts of grid missing, i have to draw another image. I would like to some better solution (if there is some for unity free).

So, I tried for test, put some transparent image below (y = -0.05, cube has size 1x1x1) and I didn’t get what I was expecting:

It seems like a rendering bug, objects are really over the image, so why so wrong rendering order? I haven’t found pattern which objects are rendered good and which wrong, solution of the bug neither. Some changes when I move camera a little, some don’t.
For example, when I step back with cube, cube will fix:

Any advices?
Thanx.

Ok, noone answered, but I found some solutions so I post it.
I solved bug when changed shader for colored flats and cube from Transparent to Decal. I think, it’s not a solution of bug, but solution in my case. If someone knows the real solution, I will be glad to read.

Solution for performance problem was to generate own mesh by this Unity - Manual: Using meshes with C# scripts

Creator of variable shape mesh:

using UnityEngine;
using System.Collections;

public class MeshCreator : MonoBehaviour {
  // create mesh prepared for exact count of flats
   public Mesh CreateEmptyMesh(int flatsCount) {
     Mesh mesh = new Mesh();
   
     mesh.vertices = new Vector3[flatsCount * 4];
     mesh.normals = new Vector3[flatsCount * 4];
     mesh.triangles = new int[flatsCount * 6];
     mesh.uv = new Vector2[flatsCount * 4];
   
     return mesh;
   }
 
  // add a single flat
   public Mesh AddFlat(Mesh mesh, int index, Vector3 position) {
     int index4 = index * 4;
     int index6 = index * 6;
   
     Vector3[] vertices = mesh.vertices;
     Vector3[] normals = mesh.normals;
     int[] triangles = mesh.triangles;
     Vector2[] uv = mesh.uv;
   
  // create vertices for flat of size 1x1
     vertices[index4] = new Vector3(-0.5f, 0, -0.5f) + position;
     vertices[index4 + 1] = new Vector3(-0.5f, 0, 0.5f) + position;
     vertices[index4 + 2] = new Vector3(0.5f, 0, 0.5f) + position;
     vertices[index4 + 3] = new Vector3(0.5f, 0, -0.5f) + position;
   
  // normal vectors pointing up for correct lighting
     Vector3 normalUp = new Vector3(0, 1, 0);
     normals[index4] = normalUp;
     normals[index4 + 1] = normalUp;
     normals[index4 + 2] = normalUp;
     normals[index4 + 3] = normalUp;
   
  // two triangles forming flat
     triangles[index6] = index4;
     triangles[index6 + 1] = index4 + 1;
     triangles[index6 + 2] = index4 + 3;
     triangles[index6 + 3] = index4 + 1;
     triangles[index6 + 4] = index4 + 2;
     triangles[index6 + 5] = index4 + 3;
   
  // stretch texture to all flat
     uv[index4] = new Vector2(0, 0);
     uv[index4 + 1] = new Vector2(1, 0);
     uv[index4 + 2] = new Vector2(1, 1);
     uv[index4 + 3] = new Vector2(0, 1);
   
     mesh.vertices = vertices;
     mesh.normals = normals;
     mesh.triangles = triangles;
     mesh.uv = uv;
   
     return mesh;
   }
}

And now just create mesh of any shape, in this case rectangular mesh of 10x100 flats

using UnityEngine;
using System.Collections;

[RequireComponent (typeof (MeshCreator))]
[RequireComponent (typeof (MeshFilter))]

public class RectangleMeshCreator : MonoBehaviour {
   void Start () {
     int width = 10;
     int lenght = 100;

     MeshCreator meshCreator = GetComponent<MeshCreator>();
     MeshFilter meshFilter = GetComponent<MeshFilter>();

  // create empty mesh of width * lenght size first
     Mesh mesh = meshCreator.CreateEmptyMesh(width * lenght);
     int index;

     for (int x = 0; x < width; x++) {
       for (int z = 0; z < lenght; z++) {
         index = x * lenght + z;
         mesh = meshCreator.AddFlat(mesh, index, new Vector3(x, 0, z));
       }
     }

  // don't forget to recalculate boundaries
     mesh.RecalculateBounds();
 
  // and finally assign created mesh
     meshFilter.mesh = mesh;
   }
}

Fps is now high, even if I have many “flats of grid” on screen, and have no need to create multiple textures for another shapes of grid.