Can i repeat only a portion of a texture?

Started by
5 comments, last by leiavoia 19 years, 10 months ago
Like, let''s say i load in an image of a tileset sheet. It has 16 32px images combined onto one 128px image. If I want to map a portion of that to a quad. no problem. But what if a want to repeat only a portion of that texture? Suppose i want a "tiled background". I can draw single quad that covers the background and set the texture coords from 0 -> 10 and it will repeat a texture 10 times. But that only works for a whole texture image. If i only wanted to repeat the first little section of it (say, the first "tile" on the tilesheet), is there any clever way to do that? The only way i can think of is to draw a new quad for each repetition of the texture portion i want -OR- make each tile a seperate texture (as you can tell, i''m trying to avoid texture switching). Any ideas?
Advertisement
You just draw 10 quads with that specific texture on them
I can''t think of a way to do that specifically (maybe someone else knows of one, can''t think of one myself) without either creating a texture for each tile you want to repeat or drawing a number of quads with the same texture. I can say that if you had to choose either one, creating a texture for each tile you need to repeat in that manner is probably better (easier to code and manage) than drawing multiple quads with part of one texture. I can''t imagine one would typically need so many of these repeating tile textures to the point where it would cause a problem though. Good luck, let me know if you find something out.

~Urayami
~Urayami
its probably possible to do it with a vertex/fragment program combo.
I''m a bit too tired atm to think about that any more, but I get the feeling its possible to do it.

If no one else cracks it i''ll try to get back to it later once i''ve had some sleep.
Hello!
U can use any part of texture as single texture. U should use TEXTURE matrix transformations
writing my own 3D engine, in 3D programming since 2003
Sorry but the texture matrix cannot help you repeat a portion of a texture, only clamp it. So the only option is fragment programs.
cant really recall what it´s called; but you could reverse the problem: first draw the quad with the repeatedtexture, then "superimpose" the nonrepeating texture onto the quad.

there is an example of this "texture-in-texture" technique in the red book...


hope it helps a bit!
"Game Maker For Life, probably never professional thou." =)

This topic is closed to new replies.

Advertisement