Axolotleless

Turbulence visializer

Feb 7th, 2025
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.73 KB | None | 0 0
  1. -- Settings
  2. local partSize = Vector3.new(.4, .4, .1) -- Size of each part
  3. local gridSize = 200 -- Number of parts along one side of the grid
  4. local gridCenter = Vector3.new(0, 0, 0) -- Center of the grid
  5. local noiseScale = 0.1 -- Scale of Perlin noise for turbulence smoothness
  6. local turbulenceScale = 1 -- Intensity of the turbulence
  7. local colorSpeed = 0.8 -- Speed of color changes
  8. local movementSpeed = 0.5 -- Speed of turbulence pattern movement
  9. local parentModelName = "FlowingTurbulenceGrid" -- Name of the Model to group the parts
  10.  
  11. -- Create a parent model to hold the parts
  12. local model = Instance.new("Model")
  13. model.Name = parentModelName
  14. model.Parent = workspace
  15.  
  16. -- Function to generate turbulence-like RGB colors
  17. local function turbulenceToColor(x, y, timeOffset)
  18.     -- Create a turbulence effect by combining multiple noise values
  19.     local offsetX = math.noise(x * noiseScale, y * noiseScale, timeOffset * movementSpeed) * turbulenceScale
  20.     local offsetY = math.noise(x * noiseScale + 10, y * noiseScale, timeOffset * movementSpeed) * turbulenceScale
  21.  
  22.     -- Compute the Perlin noise for RGB using turbulence offsets
  23.     local r = math.noise(x * noiseScale + offsetX, y * noiseScale + offsetY, timeOffset * colorSpeed)
  24.     local g = math.noise(x * noiseScale + offsetY, y * noiseScale - offsetX, timeOffset * colorSpeed)
  25.     local b = math.noise(x * noiseScale - offsetX, y * noiseScale - offsetY, timeOffset * colorSpeed)
  26.  
  27.     -- Map values from [-1, 1] to [0, 1]
  28.     r = math.clamp((r + 1) / 2, 0, 1)
  29.     g = math.clamp((g + 1) / 2, 0, 1)
  30.     b = math.clamp((b + 1) / 2, 0, 1)
  31.     return Color3.new(r, g, b)
  32. end
  33.  
  34. -- Calculate half grid size for centering
  35. local halfGridSize = (gridSize - 1) * partSize / 2
  36.  
  37. -- Store parts for animation
  38. local parts = {}
  39.  
  40. -- Generate the grid of parts
  41. for x = 0, gridSize - 1 do
  42.     for y = 0, gridSize - 1 do
  43.         -- Calculate part position
  44.         local posX = gridCenter.X + (x * partSize.X - halfGridSize.X)
  45.         local posY = gridCenter.Y + (y * partSize.Y - halfGridSize.Y)
  46.         local posZ = gridCenter.Z -- Flat 2D grid on the Z-axis
  47.         local position = Vector3.new(posX, posY, posZ)
  48.  
  49.         -- Create and configure the part
  50.         local part = Instance.new("Part")
  51.         part.Size = partSize
  52.         part.Position = position
  53.         part.Anchored = true
  54.         part.Parent = model
  55.         table.insert(parts, {Part = part, GridX = x, GridY = y})
  56.     end
  57. end
  58.  
  59. -- Animate the colors for flowing turbulence effect
  60. game:GetService("RunService").Heartbeat:Connect(function(deltaTime)
  61.     local time = wait() * movementSpeed -- Use `tick()` to create a time offset
  62.     for _, data in pairs(parts) do
  63.         local part = data.Part
  64.         local x = data.GridX
  65.         local y = data.GridY
  66.         -- Assign dynamic color based on turbulence-like noise
  67.         part.Color = turbulenceToColor(x, y, time)
  68.     end
  69. end)
Advertisement
Add Comment
Please, Sign In to add comment