You can do it in the material editor, no c++ needed.
I came up with this:
This will offset each row by some amount depending on the division denominator (5 in this case).