public static void ReleaseCache(ArraysCache cache)
 {
     lock (ARRAYS_CACHES)
     {
         cache.release();
     }
 }
        public Texture2D GetTexture()
        {
            int         xSize      = 16;
            int         zSize      = 16;
            int         chunkWidth = picWidth / 16;
            int         chunkDepth = picHeight / 16;
            Texture2D   tex        = new Texture2D(chunkWidth * xSize, chunkDepth * zSize);
            ArraysCache cache      = ArraysCacheManager.GetCache();

            for (int x = 0; x < chunkWidth; x++)
            {
                for (int z = 0; z < chunkDepth; z++)
                {
                    int[] result = mainLayer.getInts(cache, x * xSize, z * zSize, xSize, zSize);
                    cache.release();
                    for (int i = 0; i < result.Length; i++)
                    {
                        int   tempX = i % xSize;
                        int   tempZ = i / xSize;
                        Color c;
                        int   biomeId = ((result[i] & BiomeBits));

                        BiomeConfig biomeConfig = WorldConfig.Instance.GetBiomeConfigById(biomeId);
                        c = biomeConfig.color;
                        tex.SetPixel(x * xSize + tempX, z * zSize + tempZ, c);
                    }
                }
            }
            tex.Apply();
            return(tex);
        }