I’m looking for a way to have it such that I can texture a wall and dynamically adjust the height of the wall without the texture stretching. For example, if I texture a wall with bricks and graffiti, and I change the height of the wall to half its height, it should clip the top half of the texture instead of stretching the texture which results in a terrible looking squished bricks/graffiti.
Now someone in a different forum suggested that I could accomplish this by modifying the UVs of the wall mesh. Therefore, I tried to do the following : I created a cube and scaled it 1, 4, 1 so that it’s 4 units high and applied my dog’s picture to it as a texture, as you can see on the left half of my screenshot. Now for testing purposes I modify the UVs for one side of the cube and made it so that the top edge goes 3 units into negative land, my thinking being that if the top 3/4 of the image is “off-screen” (so to speak) then only the remaining bottom 1/4 will be rendered. I also changed the height of the cube to 1 to accurately portray the 1/4 size. Alas, I’m obviously barking up the wrong tree because instead of getting the bottom 1/4 of the texture with just my dogs tail I get the entire image tiled 4 times vertically.
I assume by “3 units into negative land” you mean you gave the top vertices a value of -3. If this is the case, then you are not thinking about the UV layout correctly. If you don’t want your image to tile, you will never be working with a value span larger than 1.0, meaning the difference between your minimum and maximum values used for UVs will never be greater than 1.
In the image below, Example 1 shows you the default UV selection on a un-clamped texture for the default cube face.
If instead of the whole texture you only want to get the bottom 1/3 of your texture, then you will want to modify your UV values to select a range from 0 → 0.33 on the Y axis. This should provide you with something similar to the selection shown in Example 2
“I see!!!” said the blind man to the deaf man. I’ve been looking at the UVs the wrong way… I thought that the vertexes represented the physical mesh coordinates that the texture is supposed to render on, but now I see that the UVs map to the texture instead.
Problem solved!
Thank you very much Shawn! And thanks to Krobill who gave me the idea in the first place!
Is this correct? If so, I would assume that to get the bottom 1/3 of the texture I would need to get 0.66 → 1; instead, I need 0 → 0.33 else I get the top half! What part am I wrong about?