Archived
Private
Public Access
1
0
This repository has been archived on 2026-02-04. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
2022-11-12 13:10:03 +01:00

25 lines
999 B
C#

using UnityEngine;
namespace Assets.Scripts {
public static class Noise {
public static float Get2DNoise(Vector2 pos, float offset, float scale) {
return Mathf.PerlinNoise((pos.x + 0.1f) / VoxelData.ChunkWidth * scale + offset,
(pos.y + 0.1f) / VoxelData.ChunkWidth * scale + offset);
}
public static bool Get3DNoise(Vector3 pos, float offset, float scale, float threshold) {
float x = (pos.x + offset + 0.1f) * scale;
float y = (pos.y + offset + 0.1f) * scale;
float z = (pos.z + offset + 0.1f) * scale;
float AB = Mathf.PerlinNoise(x, y);
float BC = Mathf.PerlinNoise(y, z);
float AC = Mathf.PerlinNoise(x, z);
float BA = Mathf.PerlinNoise(y, x);
float CB = Mathf.PerlinNoise(z, y);
float CA = Mathf.PerlinNoise(z, x);
return ((AB + BC + AC + BA + CB + CA) / 6f > threshold);
}
}
}