Progress is fast with my Wilderness Overhaul Mod, but there is one algorithm that gives me a hard time.
See picture for visualization of the problem:
As you can see, there are seams between the Map Pixels due to a limitation in my algrorithm.
Basically I am comparing neighbouring points on the heightmap to calculate the steepness and texture a tile as stone if the hillside is
too steep.
Problem is, I don't know how to account for the neighbouring Map Pixel when comparing heightmapSamples without getting IndexOutOfBounds.
Does anyone have an idea how to approach this?
Code: Select all
static bool SteepnessTooHigh(float steepness, NativeArray<float> heightmapData, float maxTerrainHeight, int hx, int hy, int hDim, int upperBound, int index, int tdDim, NativeArray<byte> tileData)
{
if (JobA.Col(index, tdDim) + 1 >= tdDim ||
JobA.Row(index, tdDim) + 1 >= tdDim)
{
return false;
}
else
{
float minSmpl = 0;
float maxSmpl = 0;
float smpl = minSmpl = maxSmpl = heightmapData[JobA.Idx(hy, hx, hDim)] * maxTerrainHeight;
for (int a = 0; a <= 1; a++)
{
for (int b = 0; b <= 1; b++)
{
smpl = heightmapData[JobA.Idx(hy + a, hx + b, hDim)] * maxTerrainHeight;
if (smpl < minSmpl)
{
minSmpl = smpl;
}
if (smpl > maxSmpl)
{
maxSmpl = smpl;
}
}
}
float diff = (maxSmpl - minSmpl) * 10f;
if (diff > steepness)
{
return true;
}
else
{
return false;
}
}
}