How do I sample a texture from an index texture, then scale that sample up so it tiles?

How would i go about sampling one single square of this index texture(the tall texture on the left in the example image) and then tiling that sample as if it were a normal texture being scaled with the mapping node?(as shown in the right side of the example image) I need this to be done procedurally for a game im working on for school.

The reason im trying to do this is needlessly complicated idea is because it would allow me to easily make index textures as quick presets for armor dyes in my game im making for a college project. Thank you in advance!

By the looks of it, it sounds like it should be possible to setup with Cycles. But do you know if it would be possible to transfer that technique to the game engine you’re using? What I’m thinking about is using two UV maps; one for texture coordinate lookup as usual, and the other with UV islands collapsed into points placed in the strip. Then check which index of the strip it belongs to go from there. Here I’m using random, checking in a 2D grid, and not tiling, but my approach would be kinda similar.
Since my workplace has been shut down “temporarily” and I’m currently in self quarantine (not really sick, I believe, more a precaution of just in case), I have nothing better to do. However, I’m doing some personal project for fun. So before I head into this, can you even do these sorts of tricks in the game engine?

Im trying to get this to work with math nodes as much as possible, so an extra set of UVs wont really work for me unfortunately. Sorry if im being hard headed, its just something me and my team really want to figure out. As for the technique transfer between blender and game engine, I fully understand Blender and Unity to the point that i can do a full recreation if i had something to go off of here. I just asked here because Blender is a lot easier for me to test potential solutions in

Do you have an example index texture?

yep. The preview doesnt show the whole thing, but its all there if you open it. Here is our test texture. The biggest hurdle for us i feel is the normal map in the middle(7th from the top). It is one of the detail textures. The reason i feel it is the most difficult is because it will be easy to see deformation in it and it needs to tile(repeat) instead of tile(mirror) or else it will look strange.

Found the solution. For anyone that needs to see this, here is the node setup. The number “0.071” is actually 1/14 because i have 14 tiles on my index texture. So if you have more than 14 tiles on your index texture, just change the number accordingly. So if you have 21 tiles, you will do 1/21.

This is fine for “closest” type sampling, but it’s not a great general solution, because your mipmaps are still going to be generated from the original, entire image. In your case, as soon as you start using texture filtering, you’re going to see tiling horizontal seams where your texture repeats in V whenever you zoom out. The right solution is to open up GIMP, crop the image, and save the file. Or, if trying to use a tiling texture via texture atlas, you’ll want some tiling borders around the sampled square.

Consider using math nodes instead of those confusing hard coded values. A labeled integer value node (rounded) fed into a 1/n math node. I would be able to see the point of it. 0.071 would require a lot of investigation.

Another issue here is the color space. Some uses require non color data, some uses may require different interpolation (bump).