Advertisement
Herobrinekid2

Untitled

Feb 17th, 2022 (edited)
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.88 KB | None | 0 0
  1. Basically you can generate 2D nosie and 3D(The pics you saw from my tweets were generated using 3D noise)..
  2.  
  3.  
  4. First youll need a scale or frequency as some people might say. This will control how wavy your noise will be. Second youll need a amplitude value. This will basically control how spiky/tall the noise will be. Third youll need a seed if you want random results everytime
  5.  
  6.  
  7.  
  8. Generate basic 2D noise:
  9.  
  10. -- // You need to tweak the variables to get the results you want
  11.  
  12. local Scale = 20 -- // How wavy your noise will be
  13. local Amplitude = 50 -- // How spiky/Tall your nosie will be
  14.  
  15. local Seed = math.random() -- // Seed is like a key
  16.  
  17.  
  18. local function Generate2D(X, Y)
  19.     return math.noise(X / Scale, Y / Scale, Seed) * Amplitude -- // Generate a new noise with out variables
  20. end)
  21.  
  22. for x = 1, 15 do
  23.     for y = 1, 15 do
  24.             local Noise = Generate2D(x, y)
  25.             local P = game.ServerStorage.Part:Clone()
  26.             P.Position = Vector3.new(x * 4, Noise, y * 4) -- // Multiply by your block size to space them out and position                                                  the block on the noise scale
  27.             P.Parent = game.Workspace.Terrain
  28.         end
  29.     end
  30. end
  31.  
  32.  
  33. -- // Generate 3D Noise(The fun stuff omg)
  34. local Scale = 20
  35. local Amplitude = 50
  36.  
  37. local Seed = math.random()
  38.  
  39.  
  40. local function Generate3D(X, Y, Z)
  41. -- // Were basically creating three 2nd noises and then combining them into a 3D one
  42.     local XN = math.noise(X / Scale, Z / Scale, Seed) * Amplitude
  43.     local YN = math.noise(Y / Scale, X / Scale, Seed) * amplitude
  44.     local ZN = math.noise(Y / Scale, Z / Scale, Seed) * Amplitude
  45.  
  46.     local Final_Noise = XN + YN + ZN + Y
  47.  
  48.     return Final_Noise
  49. end)
  50.  
  51.  
  52. for x = 1, 15 do
  53.     for y = 1, 15 do
  54.         for z = 1, 15 do
  55.             local Noise = Generate3D(x, y, z)
  56.  
  57.             if Noise < .5 then
  58.                 local P = game.ServerStorage.P:Clone()
  59.                 P.Position = Vector3.new(x * 4, y * 4, z * 4)
  60.                 P.Parent = game.Workspace.Terrai
  61.             end
  62.         end
  63.     end
  64. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement