diff --git a/Proc Gen E20/Assets/Scripts/HeightMapGenerator.cs b/Proc Gen E20/Assets/Scripts/HeightMapGenerator.cs index fc84aef2..7af0b422 100644 --- a/Proc Gen E20/Assets/Scripts/HeightMapGenerator.cs +++ b/Proc Gen E20/Assets/Scripts/HeightMapGenerator.cs @@ -4,6 +4,8 @@ public static class HeightMapGenerator { + static float[,] falloffMap; + public static HeightMap GenerateHeightMap(int width, int height, HeightMapSettings settings, Vector2 sampleCentre) { float[,] values = Noise.GenerateNoiseMap (width, height, settings.noiseSettings, sampleCentre); @@ -12,9 +14,15 @@ public static HeightMap GenerateHeightMap(int width, int height, HeightMapSettin float minValue = float.MaxValue; float maxValue = float.MinValue; + if (settings.useFalloff) { + if (falloffMap == null) { + falloffMap = FalloffGenerator.GenerateFalloffMap (width); + } + } + for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { - values [i, j] *= heightCurve_threadsafe.Evaluate (values [i, j]) * settings.heightMultiplier; + values [i, j] *= heightCurve_threadsafe.Evaluate (values [i, j] - (settings.useFalloff ? falloffMap[i, j] : 0)) * settings.heightMultiplier; if (values [i, j] > maxValue) { maxValue = values [i, j]; diff --git a/Proc Gen E21/Assets/Scripts/HeightMapGenerator.cs b/Proc Gen E21/Assets/Scripts/HeightMapGenerator.cs index fc84aef2..7af0b422 100644 --- a/Proc Gen E21/Assets/Scripts/HeightMapGenerator.cs +++ b/Proc Gen E21/Assets/Scripts/HeightMapGenerator.cs @@ -4,6 +4,8 @@ public static class HeightMapGenerator { + static float[,] falloffMap; + public static HeightMap GenerateHeightMap(int width, int height, HeightMapSettings settings, Vector2 sampleCentre) { float[,] values = Noise.GenerateNoiseMap (width, height, settings.noiseSettings, sampleCentre); @@ -12,9 +14,15 @@ public static HeightMap GenerateHeightMap(int width, int height, HeightMapSettin float minValue = float.MaxValue; float maxValue = float.MinValue; + if (settings.useFalloff) { + if (falloffMap == null) { + falloffMap = FalloffGenerator.GenerateFalloffMap (width); + } + } + for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { - values [i, j] *= heightCurve_threadsafe.Evaluate (values [i, j]) * settings.heightMultiplier; + values [i, j] *= heightCurve_threadsafe.Evaluate (values [i, j] - (settings.useFalloff ? falloffMap[i, j] : 0)) * settings.heightMultiplier; if (values [i, j] > maxValue) { maxValue = values [i, j];