-
-
Save todorok1/ca2ad2d1a44b1ef81c5dd3a2931a49f1 to your computer and use it in GitHub Desktop.
TerrainのHeightMapを生成するスクリプト(エディタ拡張のクラス)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <Summary> | |
/// 複数のパーリンノイズをかけ合わせるメソッドです。 | |
/// </Summary> | |
float GetMultiplePerlinNoise(float xPos, float yPos, int terrainSizeX, int terrainSizeZ, TerrainGenerator generator) | |
{ | |
// 乱数のシードを設定します。 | |
Random.InitState(generator.seed); | |
// パーリンノイズの値を指定回数だけ乗算します。 | |
float perlinValue = Mathf.PerlinNoise(xPos, yPos); | |
for (int i = 0; i < generator.multipleTimes; i++) | |
{ | |
float offsetValue = Random.value; | |
float xOffset = offsetValue * terrainSizeX; | |
float yOffset = offsetValue * terrainSizeZ; | |
float scaleOffset = Random.Range(0.8f, 1.25f); | |
float xValue = (xPos + xOffset) * scaleOffset; | |
float yValue = (yPos + yOffset) * scaleOffset; | |
float value = Mathf.PerlinNoise(xValue, yValue); | |
perlinValue *= Mathf.Clamp01(value); | |
} | |
return perlinValue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment