//These two functions are only used so different threads don't base on the same data and fs up public Spawnable(Spawnable spawnable) { this._noiseMergeType = spawnable._noiseMergeType; this._noiseSettingsData = spawnable._noiseSettingsData; this._subSpawners = spawnable._subSpawners; this._parentOnly = spawnable._parentOnly; this._rotationAmount = spawnable._rotationAmount; this._noiseStartPoint = spawnable._noiseStartPoint; this._thickness = spawnable._thickness; this._uniformSpreadAmount = spawnable._uniformSpreadAmount; this._randomSpread = spawnable._randomSpread; this._offsetAmount = spawnable._offsetAmount; this._spawnFixedHeight = spawnable._spawnFixedHeight; this._size = spawnable._size; this._spacing = spawnable._spacing; this._othersCanSpawnInside = spawnable._othersCanSpawnInside; this._spawnDifferencial = spawnable._spawnDifferencial; this._softMinAmount = spawnable._softMinAmount; this._hardMinHeight = spawnable._hardMinHeight; this._softMaxAmount = spawnable._softMaxAmount; this._hardMaxHeight = spawnable._hardMaxHeight; this._surfaceNormalAmount = spawnable._surfaceNormalAmount; this._pointAlongNormalRandomness = spawnable._pointAlongNormalRandomness; this._softMinSlope = spawnable._softMinSlope; this._hardMinSlope = spawnable._hardMinSlope; this._softMaxSlope = spawnable._softMaxSlope; this._hardMaxSlope = spawnable._hardMaxSlope; this._noise = spawnable._noise; this._offsetNoise = spawnable._offsetNoise; this._spreadNoise = spawnable._spreadNoise; this._prefabs = spawnable._prefabs; }
public static float[,] MergeNoise(int mapWidth, int mapHeight, int detailLevel, NoiseSettingsDataMerge[] settingsMerge_1, float[,] noise_2, NoiseMergeType noiseMergeType, Vector2 sampleCenter) { float[,] noise_1 = GenerateNoiseMap(mapWidth, mapHeight, detailLevel, settingsMerge_1, sampleCenter); return(MergeNoise(mapWidth / detailLevel, mapHeight / detailLevel, noise_1, noise_2, noiseMergeType, sampleCenter, false)); }
public static float[,] MergeNoise(int width, int height, int detailLevel, NoiseSettings noiseSettings_1, float[,] noise_2, NoiseMergeType noiseMergeType, Vector2 center) { float[,] noise_1 = GenerateNoiseMap(width, height, detailLevel, noiseSettings_1, center); return(MergeNoise(width / detailLevel, height / detailLevel, noise_1, noise_2, noiseMergeType, center, noiseSettings_1.Mask)); }
//Base for all merge noise functions, combine two different noise according to mode public static float[,] MergeNoise(int width, int height, float[,] noise_1, float[,] noise_2, NoiseMergeType noiseMergeType, Vector2 center, bool mask) { float[,] finalNoise = new float[width, height]; float maxHeight = 1f; float minHeight = 0f; if (noiseMergeType == NoiseMergeType.ONLY_FIRST) { finalNoise = noise_1; } else if (noiseMergeType == NoiseMergeType.ONLY_SECOND) { finalNoise = noise_2; } else { for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { if (noiseMergeType == NoiseMergeType.ADD) { finalNoise[i, j] = noise_1[i, j] + noise_2[i, j]; if (mask) { finalNoise[i, j] = Mathf.Clamp(finalNoise[i, j], 0, 1); } if (i == 0 && j == 0) { maxHeight = 2f; minHeight = 0f; } } else if (noiseMergeType == NoiseMergeType.MULTIPLY) { finalNoise[i, j] = noise_1[i, j] * noise_2[i, j]; } else if (noiseMergeType == NoiseMergeType.SUBTRACT) { finalNoise[i, j] = noise_1[i, j] - noise_2[i, j]; if (i == 0 && j == 0) { maxHeight = 1f; minHeight = -1f; } } else if (noiseMergeType == NoiseMergeType.DIVIDE) { if (noise_2[i, j] != 0) { finalNoise[i, j] = noise_1[i, j] / noise_2[i, j]; } else { finalNoise[i, j] = noise_1[i, j] / 0.0001f; } if (i == 0 && j == 0) { maxHeight = 1 / 0.0001f; minHeight = 0f; } } } } } ////Normalize //for (int y = 0; y < height; y++) // for (int x = 0; x < width; x++) // { // finalNoise[x, y] = Mathf.InverseLerp(minHeight, maxHeight, finalNoise[x, y]); // } return(finalNoise); }