Advertisement
GaryScripts

randPerlinNoiseRoblox

Mar 28th, 2022
1,272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. local objFogFolder = workspace:WaitForChild("FogObjects")
  2.  
  3. local fogScrnSize = 100
  4. local resolution = 100
  5. local random = Random.new()
  6.  
  7. local freq = math.floor(random:NextNumber(0, 10)) + random:NextNumber(0, 2)
  8. local amp = math.floor(random:NextNumber(0, 15)) + random:NextNumber(0, 1.645)
  9. workspace.Baseplate.Position = Vector3.new(0, -24, 0)
  10.  
  11. local function getHeight(x, z)
  12.     local noiseHeight = math.noise(x / resolution * freq, z / resolution * freq)
  13.     noiseHeight = math.clamp(noiseHeight, -0.5, 0.5) + 0.5
  14.    
  15.     return noiseHeight
  16. end
  17.  
  18. for x = 0, fogScrnSize do
  19.     for z = 0, fogScrnSize do
  20.         local part = Instance.new("Part", objFogFolder)
  21.         part.Anchored = true
  22.         part.Size = Vector3.new(1, 1, 1)
  23.        
  24.         local hgh = getHeight(x, z)
  25.        
  26.         part.Position = Vector3.new(x, hgh * amp, z)
  27.         part.Color = Color3.new(hgh, hgh, hgh)
  28.     end
  29.    
  30.     game:GetService("RunService").Heartbeat:Wait()
  31. end
  32.  
  33. print(freq, amp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement