bool CheckIfSurface(Vector3Int voxelIndexInLayer, ChunkLayer <Voxel> voxelLayer)
    {
        if (IsLayerBorder(voxelLayer, voxelIndexInLayer) == false)
        {
            Voxel thisVoxel = voxelLayer.GetVoxel(voxelIndexInLayer);
            if (thisVoxel.IsAir)
            {
                return(false);
            }
            foreach (int x in sides)
            {
                foreach (int y in sides)
                {
                    foreach (int z in sides)
                    {
                        Vector3Int index = voxelIndexInLayer + new Vector3Int(x, y, z);

                        Voxel voxel = voxelLayer.GetVoxel(index);
                        if (voxel.IsAir)
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
        return(true); // assuming border voxels are a
    }
    void BufferSingleVoxel(ChunkLayer <Voxel> chunkLayer, Vector3Int indexInLayer, Vector3Int index3D)
    {
        int index = index3D.z * slSqr + index3D.y * sl + index3D.x;

        Voxel voxel = chunkLayer.GetVoxel(indexInLayer);

        try
        {
            renderBuffer[index] = ConvertToArrayDensity(voxel);
        }
        catch
        {
            Debug.Log("hey");
        }
    }
    public void CalculateVoxel(Vector3Int voxelIndexInLayer, ChunkLayer <Voxel> voxelLayer)
    {
        Voxel voxel = voxelLayer.GetVoxel(voxelIndexInLayer);

        if (CheckIfSurface(voxelIndexInLayer, voxelLayer))
        {
            voxel.IsSurface = true;
            Debug.DrawRay(voxelIndexInLayer, Random.insideUnitSphere * 0.2f, Color.green, 1000);
            surfaceCounter++;
        }
        else
        {
            voxel.IsSurface = false;
            internalCounter++;
        }
        voxelLayer.SetVoxel(voxelIndexInLayer, voxel);
    }
    public T GetVoxel(Vector3 position)
    {
        Vector3Int voxelIndexInLayer = GetIndexInLayer(position, mainLayer);

        return(mainLayer.GetVoxel(voxelIndexInLayer));
    }