Generating a seamless texture with noise

Hey there,

I would like to generate a tileable texture with the built-in noise function.
Anyone know if it is possible to “tile” the noise so that no seams are visible, some magic factor maybe ?

I looked up some stuff but I cannot make anything convincing out of it using the built-in function :frowning:

Cheers,

Xavier

You could use noise on a sprite and scale it up.


function setup()
    i = image(2,2)
    for x = 1, 2 do
        for y = 1, 2 do
            i:set(x,y,math.random(255),math.random(255),math.random(255),255)
        end
    end
end

function draw()
    background(40, 40, 50)
    scale(300)
    sprite(i,1,1)
end

I didn’t use noise and scaled it up a ridiculous amount.

@Ipad41001 - that’s very smart, and it will do fine for now :smiley:

Thanks a lot,

Xavier

Have you tried a power-of-two sized array/image? I read somewhere that that’s supposed to make the resulting perlin noise seamlessly tileable.

Not seamless, but it will make the texture repeat when the texture coordinates exceed 1 or are less than 0. For example:

 (0,5) -------------- (5,5)
   |                     |
   |                     |
   |                     |
   |                     |
   |                     |
   |                     |
   |                     |
 (0,0) -------------- (5,0)

A rectangle with the above texture coordinates (on a mesh), using a power-of-two texture, will repeat 5 times. A non-power-of-two texture will not repeat and will instead clamp the border’s pixel colours.

@Xavier Not quite what you’re after, but the ‘draw a road’ code I posted the other day generates a noisy texture, and could perhaps be repurposed and tiled using the technique @Simeon suggested.

http://twolivesleft.com/Codea/Talk/discussion/707/help-rendering-a-realistic-road#Item_21