Consider using Tobler's hiking function for calculating path finding cost surface
https://en.wikipedia.org/wiki/Tobler%27s_hiking_function
I tried replacing your existing cost function with Tobler's hiking function and found the results to be more pleasing for my use case. Clearly it wouldn't apply if you're creating roads for cars, etc. Given that the cost surface is simply another raster, it may make sense to feed in the cost surface as a WorldMatrix -- just musing.
My Tobler hack in Pathfinder.cs is below.
if (passable)
{
//nNewWeight = weights.arr[pos] +
// diagonalFactor * distanceFactor +
// elevation * elevation * elevationFactor +
// dirDelta * straightenFactor;
float dist = diagonalFactor * pixelSize;
float deltaY = Mathf.Abs(nHeight - heights.arr[pos]) * heights.worldSize.y;
// Tobler's hiking function
// https://en.wikipedia.org/wiki/Tobler%27s_hiking_function
// friction unit is seconds
float m = deltaY / dist;
nNewWeight = .6f * Mathf.Exp(3.5f * Mathf.Abs(m + 0.05f)) * dist + weights.arr[pos];
if (nHeight * heights.worldSize.y < 25) nNewWeight = maxWeight + 1;
}
else
nNewWeight = maxWeight + 1;