Texture the quad with different parts of texture
Posted
by
PolGraphic
on Game Development
See other posts from Game Development
or by PolGraphic
Published on 2012-12-11T23:21:05Z
Indexed on
2012/12/12
5:17 UTC
Read the original article
Hit count: 353
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.zw - textureCoordinates.xy) + textureCoordinates.xy; //textureCoordinates.xy = fragments' offset
Will give me the texture part replaying.
© Game Development or respective owner