Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. public static float[,] GenerateNoiseMap(int mapWidth, int mapHeight, float scale) {
  2. float[,] noiseMap = new float[mapWidth,mapHeight];
  3.  
  4. if (scale <= 0) {
  5. scale = 0.0001f;
  6. }
  7.  
  8. for (int y = 0; y < mapHeight; y++) {
  9. for (int x = 0; x < mapWidth; x++) {
  10. float sampleX = x / scale;
  11. float sampleY = y / scale;
  12.  
  13. float perlinValue = Mathf.PerlinNoise (sampleX, sampleY);
  14. noiseMap [x, y] = perlinValue;
  15. }
  16. }
  17.  
  18. return noiseMap;
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement