When you have an image withvertical and horizontal tiles, the patternIndex works incorect..
It should be :
0 1 2 3
4 5 6 7 ...

but actually it is:
0 2 4 6
1 3 5 7 ...

I tried to find the reason but I wasn't succesfull.