Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a 2D quad. Let say it's position is (5,10) and size is (7,11).

I want to texture it with one texture, but using three different parts of it. I want to texture the part of quad from x = 5 to x = 7 with part of texture from U = 0 to U = 0.5 (replaying it after achieving 0.5, so I will have 4 same 0.5-lenght fragments). The second one with some other part of texture (also repeating it) and third in the same style.

But, how to achieve it?

I know that:

float2 tc = fmod(input.TexCoord, - textureCoordinates.xy) + textureCoordinates.xy; //textureCoordinates.xy = fragments' offset

Will give me the texture part replaying.

share|improve this question
You need a vertex for a texture coordinate. You can't apply texture coordinates mid-triangle (as far as I know). Just break your quad into smaller quads, or make a new texture that matches your desired output. – Byte56 Dec 11 '12 at 23:28
You could also use some kind of weird shader, but breaking it into multiple quads seems like the optimal solution. – AlchemicalApples Dec 12 '12 at 1:46
up vote 2 down vote accepted

The easiest way to do this is to break the quad into multiple smaller quads. You'll need a to input a coordinate for the texture, and the easiest way to do that is with a vertex.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.