Shuffle Tiles

This shader splits input coordinates into tiles, which are shuffled randomly. You can use it with an image node, and split any image into a set of tiles, which are scattered randomly.

Example texture

Shuffled texture.

The shader.

// Shuffle Tiles

shader sTiles(
    point inP = P,
    int nTiles = 1,
    output point outBUV = point(0.0),
    output float outUV[2] = {0.0}
    )
{
    float U = 1.0/nTiles*mod(nTiles*inP[0]+1.0e5,1.0);
    float V = 1.0/nTiles*mod(nTiles*inP[1]+1.0e5,1.0);

    float tileU = 1.0/nTiles*floor(nTiles*noise ("cell", nTiles*inP, 0.0));
    float tileV = 1.0/nTiles*floor(nTiles*noise ("cell", nTiles*inP, 10.0));

    float signU = sign(0.5-noise ("cell", nTiles*inP, 0.0));
    float signV = sign(0.5-noise ("cell", nTiles*inP, 10.0));

    outUV[0] = tileU+signU*U;
    outUV[1] = tileV+signV*V;

    outBUV = point(outUV[0], outUV[1], 0);
}
1 Like