Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local component = require("component")
- local holo = component.hologram
- local noiseWidth = 48
- local noiseHeight = 48
- local maxHeight = 32
- local noise = {}
- for i = 0, noiseWidth - 1 do
- noise[i] = {}
- end
- local function generateNoise()
- for x = 0, noiseWidth - 1 do
- for y = 0, noiseHeight - 1 do
- noise[x][y] = math.random()
- end
- end
- end
- local function smoothNoise(x, y)
- local fractX = x - math.floor(x)
- local fractY = y - math.floor(y)
- local x1 = (math.floor(x) + noiseWidth) % noiseWidth
- local y1 = (math.floor(y) + noiseHeight) % noiseHeight
- local x2 = (x1 + noiseWidth - 1) % noiseWidth
- local y2 = (y1 + noiseHeight - 1) % noiseHeight
- local value = 0
- value = value + fractX * fractY * noise[x1][y1]
- value = value + fractX * (1 - fractY) * noise[x1][y2]
- value = value + (1 - fractX) * fractY * noise[x2][y1]
- value = value + (1 - fractX) * (1 - fractY) * noise[x2][y2]
- return value
- end
- local function turbulence(x, y, size)
- local value = 0
- local iSize = size
- while (size >= 1) do
- value = value + smoothNoise(x / size, y / size) * size
- size = size / 2
- end
- return value / iSize / 2
- end
- generateNoise()
- holo.clear()
- local m = 0
- for x = 0, noiseWidth - 1 do
- for y = 0, noiseHeight - 1 do
- local h = math.floor(maxHeight * turbulence(x, y, 64))
- local mask = 0
- for i = 0, h do
- mask = mask + 2^i
- end
- holo.set(x + 1, y + 1, mask)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement