public static    GPUSurfaceBiome[] CreateGPUSurfaceBiomes(SurfaceBiomeDatabase.SurfaceBiomeList surfaceBiomes)
 {
     GPUSurfaceBiome[] gpuSurfaceBiomes = new GPUSurfaceBiome[surfaceBiomes.Count];
     for (int i = 0; i < surfaceBiomes.Count; i++)
     {
         gpuSurfaceBiomes[i] = new GPUSurfaceBiome(surfaceBiomes[i]);
     }
     return(gpuSurfaceBiomes);
 }
        public void Init(string mapSeed, int cubesPerAxis, float chunkSize, SurfaceBiomeDatabase.SurfaceBiomeList surfaceBiomes, CaveBiomeDatabase.CaveBiomeList caveBiomes, List <Region> regions)
        {
            //GPU
            Vector3[]         SurfaceOctaveOffsets = GenerateMapOctaveOffsets(mapSeed, false);
            Vector3[]         CaveOctaveOffsets    = GenerateMapOctaveOffsets(mapSeed, true);
            GPUSurfaceBiome[] GPUSurfaceBiomes     = GPUSurfaceBiome.CreateGPUSurfaceBiomes(surfaceBiomes);
            GPUCaveBiome[]    GPUCaveBiomes        = GPUCaveBiome.CreateGPUCaveBiomes(caveBiomes);
            GPURegion[]       GPURegions           = GPURegion.CreateGPURegions(regions);

            //Kernal
            Kernel = NoiseShader.FindKernel("NoiseGenerator");

            //Sets
            NoiseShader.SetInts("ThreadDimensions", new int[3] {
                cubesPerAxis, cubesPerAxis, cubesPerAxis
            });
            NoiseShader.SetFloat("ChunkSize", chunkSize);
            NoiseShader.SetFloat("CubesPerAxis", cubesPerAxis);
            NoiseShader.SetInt("SurfaceOctaves", SurfaceOctaves);
            NoiseShader.SetFloat("SurfaceLacunarity", SurfaceLacunarity);
            NoiseShader.SetFloat("SurfaceScale", SurfaceScale);
            NoiseShader.SetInt("CaveOctaves", CaveOctaves);
            NoiseShader.SetFloat("CaveLacunarity", CaveLacunarity);
            NoiseShader.SetFloat("CaveScale", CaveScale);
            NoiseShader.SetInt("SurfaceBiomesCount", GPUSurfaceBiomes.Length);
            NoiseShader.SetInt("CaveBiomesCount", GPUCaveBiomes.Length);
            NoiseShader.SetInt("RegionsCount", GPURegions.Length);

            //StructuredBuffer sets
            SurfaceOctaveOffsetsBuffer = new ComputeBuffer(SurfaceOctaves, Stride.Vector3Stride);
            CaveOctaveOffsetsBuffer    = new ComputeBuffer(CaveOctaves, Stride.Vector3Stride);
            GPUSurfaceBiomesBuffer     = new ComputeBuffer(GPUSurfaceBiomes.Length, GPUSurfaceBiome.Stride);
            GPUCaveBiomesBuffer        = new ComputeBuffer(GPUCaveBiomes.Length, GPUCaveBiome.Stride);
            GPURegionsBuffer           = new ComputeBuffer(GPURegions.Length, GPURegion.Stride);
            SurfaceOctaveOffsetsBuffer.SetData(SurfaceOctaveOffsets);
            CaveOctaveOffsetsBuffer.SetData(CaveOctaveOffsets);
            GPUSurfaceBiomesBuffer.SetData(GPUSurfaceBiomes);
            GPUCaveBiomesBuffer.SetData(GPUCaveBiomes);
            GPURegionsBuffer.SetData(GPURegions);
            NoiseShader.SetBuffer(Kernel, "SurfaceOctaveOffsets", SurfaceOctaveOffsetsBuffer);
            NoiseShader.SetBuffer(Kernel, "CaveOctaveOffsets", CaveOctaveOffsetsBuffer);
            NoiseShader.SetBuffer(Kernel, "SurfaceBiomes", GPUSurfaceBiomesBuffer);
            NoiseShader.SetBuffer(Kernel, "CaveBiomes", GPUCaveBiomesBuffer);
            NoiseShader.SetBuffer(Kernel, "Regions", GPURegionsBuffer);
        }