I have a texture and the rectangle.
I want repeat the texture on that rectangle. But only a part of it.
Let say I want to use texture coordinates from 0.25 to 0.75 on X and Y and repeat it 2 times.
If I set the coords of the rectangle’s vertexes to:
(0.25, 0.25)
(0.25, 0.75 * 2)
(0.75 * 2, 0.25)
(0.75 * 2, 0.75 * 2)
That will not repeat texture from 0.25 to 0.75 two times, but will produce texture from 0.25 to 1.0 and from 1.0 to 0.25, which is different.
How to achieve my goal, not changing the texture, using part of it and repeat only that part?
Note that I don’t want to add more vertexes to the rectangle.
Its pretty easy to achieve with fragment shader:
This shader is symmetrical so lookup window moves along diagonal. But you can apply own offset and scale to each texture coordinate component separately then window will move totally freely.