I have the Image as texture. example
And I want to repeat only the part of this texture. For example the third rectangle in first row from [0.5,0] to [0.75,0.25]. (the brown one)
Is it any way to do it in Webgl 2 ?
ps. maybe it could be done using textureOffset and something else...
Thank you!
To repeat part of a texture you can do that in the shader by setting some uniforms that define the section of the texture you wish to repeat.
You can then repeat the texture as follows
There is one issue when you use a texture that is not set with
NEAREST
as the interpolation will case pixels at the edge to bleed in. This will cause unwanted visible seams where the texture repeats.The easiest way to fix is the reduce the repeating pattern size by a pixel and the pattern start position in by half a pixel.
Example
Example creates a texture (image on right) and then renders a random part of that text in the canvas on the left. The repeat set to a random amount each new render