0
\$\begingroup\$

Weird image

I was just messing around with perlin noise and got this. Wondering if anyone knows what it is or has seen it before.

Here is the code(LUA with love2d engine):

function love.load()
    love.window.setMode( 1920, 1080, {fullscreen=false})
    --Assuming you called the module perlin.lua
    newperlin = require("perlin2")
    --newperlin is a function that generates Perlin noise objects:

    myperlin = newperlin()
    --333 is seed
    myperlin = newperlin(333)
    mapHeight = 400
    mapWidth = 400

    --then, to create noise:
    scale = 0.007
    map = {}
    for x = 0, mapWidth - 1 do
        map[x] = {}
        for y = 0, mapHeight - 1 do
            map[x][y] = 0
            map[x][y] = --[[map[x][y] + --]](myperlin:noise(x * scale, y 
              * scale) + 1) / 2.0 * 255.0 
            --The following lines change it from a cloud to a weird image
            smin=0; smax=255
            map[x][y] =  math.floor(( map[x][y] - (-0.5) ) * 255 / ( 0.5 
              - (-0.5) ) + 0)
        end
    end
end
function love.draw()
    for x = 0, mapWidth - 1 do
        for y = 0, mapHeight - 1 do
        love.graphics.setColor(map[x][y], map[x][y], map[x][y], 255)
        love.graphics.point(x,y) 
        end
    end
end

function love.update()

end

function love.keyreleased(key)
    if key == "escape" then
        love.event.quit()
    end
end

and here is perlin.lua:

\$\endgroup\$
2
\$\begingroup\$

You are going outside the 0..255 range. That's why you see these color bands, since you are goint the whole range of values between 0..255 for every integer.

You are multiplying by 255 twice. This has nothing to do with perlin noise.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.