Weird texture stretching problem.

I’m making a 2D game and struggling with a weird problem with using texture on a quad. The actual scenario is more involved, but I was able to reduce it to these simple steps:

  1. Create a 512x512 background .png image and drop it into the Assets folder. A sprite texture is created.

  2. Create a quad and set its size to 30x30x1.

  3. Drop the sprite texture into the quad Inspector area. Now the image is displayed on the quad.

  4. Add offset 0.2 to the texture. The image shifts by 20% and wraps inside the quad. So far so good. The weird part follows.

  5. Go to the image import settings, change format to Truecolor and hit “Apply”. Now part of the image is lost. It seems that a one-pixel column is stretched.

  6. Try to go back to format Compressed and observe that the image is still distorted.

I’m new to Unity, so please let me know am I doing something wrong or is it a bug?


While I don’t have an immediate answer to your problem, I can offer some information that may be relevant to figuring out what is going on.

You may want to try alternative shaders or one that is specific to sprites if you aren’t already using one. The thing that makes offsetting work in Unity (even though you can totally calculate the offset yourself and not use this macro, although it’s unlikely that you’re doing this) is a macro called TRANSFORM_TEX inside of a Vertex program.

If your texture is compressed by default and then being changed to truecolor afterwards, the compression algorithm could be working against the offset / tiling to distort the image. One solution could be to just change the shader to something else and then back to the original (however if this is a runtime error, that would be an ugly solution!)

Try importing the image in the same way as your steps described as a truecolor image before you ever apply it to your quad and then afterwards try changing it to compressed. While this may not be exactly what you want to do, it may point to the compression throwing off the offsetting as I had described earlier.