WasTabon
@WasTabon

Как внедрить seed для рандомизации шума перлина?

Вот код создания шума
public class PerlinNoise : MonoBehaviour
{
    public float[,] noiseMap;
    
    public void GeneratePerlinNoise(int Width, int Height, float scale)
    {
        noiseMap = new float[Width, Height];

        for (int x = 0; x < Width; x++)
        {
            for (int y = 0; y < Height; y++)
            {
                float XPos = x / scale;
                float YPos = y / scale;

                float noiseValue = Mathf.PerlinNoise(XPos, YPos);
                noiseMap[x, y] = noiseValue;
            }
        }
    }
}

а вот текстуры его

public class NoiseTexture : MonoBehaviour
{
    public int seed;
    [SerializeField] private int _width;
    [SerializeField] private int _height;
    [SerializeField] private float _scale;
    
    [SerializeField] private PerlinNoise _perlinNoise;

    private Texture2D _texture2D;

    private void Start()
    {
        _texture2D = new Texture2D(_width, _height);

        _perlinNoise.GeneratePerlinNoise(_width, _height, _scale);
        GenerateTexture(_width, _height, _scale, seed);

        Renderer renderer = GetComponent<Renderer>();
        renderer.material.mainTexture = _texture2D;
    }

    private void GenerateTexture(int Width, int Height, float Scale, int seed)
    {
        System.Random prng = new System.Random(seed);
        for (int x = 0; x < Width; x++)
        {
            for (int y = 0; y < Height; y++)
            {
                _texture2D.SetPixel(x, y, new Color(_perlinNoise.noiseMap[x, y], _perlinNoise.noiseMap[x, y], _perlinNoise.noiseMap[x, y]));
            }
        }
        _texture2D.Apply();
    }
}

Не очень понимаю как можно сделать радномизацию этого с сидом
  • Вопрос задан
  • 66 просмотров
Решения вопроса 1
freeExec
@freeExec
Участник OpenStreetMap
float noiseValue = Mathf.PerlinNoise(XPos + RandomX, YPos + RandomY);
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы