Got unexpected results from perlin noise. Wondering what it is doing?

Got unexpected results from perlin noise. Wondering what it is doing?

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:

Replay

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.

Category: lua Time: 2016-07-30 Views: 0

Related post

iOS development

Android development

Python development

JAVA development

Development language

PHP development

Ruby development

search

Front-end development

Database

development tools

Open Platform

Javascript development

.NET development

cloud computing

server

Copyright (C) avrocks.com, All Rights Reserved.

processed in 0.246 (s). 12 q(s)