My generated terrain chunks have gaps between them:
I'm using Compute Shader and Simplex Noise from FastNoiseLite library to generate noise:
#pragma kernel GenerateNoise
#include "Includes\FastNoiseLite.compute"
RWStructuredBuffer<float> _Weights;
static const uint numThreads = 8;
int _chunkSize;
int _seed;
float _NoiseScale;
float _Amplitude;
float _Frequency;
int _Octaves;
float _GroundPercent;
float chunkPosX;
float chunkPosY;
int coordToIndex(int x, int y, int z)
{
return x + _chunkSize * (y + _chunkSize * z);
}
[numthreads(numThreads, numThreads, numThreads)]
void GenerateNoise (uint3 id : SV_DispatchThreadID)
{
fnl_state noise = fnlCreateState(_seed);
noise.noise_type = FNL_NOISE_OPENSIMPLEX2;
noise.fractal_type = FNL_FRACTAL_RIDGED;
noise.frequency = _Frequency;
noise.octaves = _Octaves;
float3 pos = id * _NoiseScale;
float ground = -pos.y + (_GroundPercent * _chunkSize);
float n = ground + fnlGetNoise3D(noise, id.x + (chunkPosX * _chunkSize), id.y, id.z + (chunkPosY * _chunkSize)) * _Amplitude;
_Weights[coordToIndex(id.x, id.y, id.z)] = n;
}
Chunks have size of 16. I tried to increase my chunks size by 1, but this is impossible because numThread = 8 and as a result when I dispatched shader I have threads per group equal to 2 so my noise values for "extended parts" of chunks don't calculated.
Any ideas how to fix these "gaps"?