Phew! Perlin noise function finally working.