# How to make part of the Texture not to be scaled.?

I am new to LibGdx, i was doing one example for my learning and struck with this question, i had searched in google but i am not able to find the answer for this.

1) How to make part of the Texture not to be scaled.

as you can see in the image i am reducing the height of bottom pipes so that the top pipe scale is reduced to fit the height given but i want the top part of the pipe not to be scaled.

in this example whole pipe is one texture, for fixing this problem i thought to split the top and body to separate texture and set height for only body but i thought there should be some other solution so that only i had put this question here.

• Split the tube into 2 parts, stretching and static size. Commented Feb 15, 2014 at 10:05
• Thanks for replay but is there is no other option for doing this, without splitting.? Commented Feb 15, 2014 at 10:07
• No. There's no way of both stretching and not stretching an image at the same time. (Discounting quantum mechanics.)
– Anko
Commented Feb 15, 2014 at 12:54
• Well, ok, you could implement morph target animation, but that would be overkill for a Flappy Bird clone.
– Anko
Commented Feb 15, 2014 at 13:20
• Hi Anko thanks for your replay, I am using this for learning only, I had taken Flappy Bird because it is easy to learn with less graphics. Commented Feb 15, 2014 at 13:34

Option #1: Split tubes into 2 parts, the tube and the rim. So that you stretch the tube to be as long as you need it and the rim part is always the same size.

Option #2: Make the tubes to be always the same length and hide the ends behind the walls.

You can scale the texture coordinates over the region of the texture that you want to manipulate.

Typically, your textures are drawn using linear interpolation ("lerp"), so the texture is evenly distributed / linearly scaled across the target polygon, like so:

However, you can manipulate this to give non-linear interpolation by changing your texture coordinates. For instance,

With that example, 1. the top two quad rows contain the top 50% of the texture. 2. The third row (from the top) contains 40% of the texture (from 0.5 to 0.9) 3. The last row contains only the last 10% of the texture

This causes the texture to be stretched.

This is flexible in that you can dynamically manipulate the texture coordinates, preferably in fragment shader. I'd pass in a uniform indicating how far you wanted the platform to extend vertically, and figure out the texel coordinates based on that.

The other option is to manipulate the vertex coordinates of the 3rd row to extend the platform, which will have the same effect. As long as you have "stretching" in your tex coords, you'll get the effect you are looking for.