- Home /
HUGE Texture problems on iPhone when using animated UVs
Hi!
I have a few objects that use UV offset animations, by using this code:
renderer.material.SetTextureOffset("_MainTex", new Vector2(0, offset));
For example, there is a river flowing downstream. It uses a 256x256 texture, which displays really really bad on the iPhone, like it was 16x16. Even worse, sometimes it displays right, and sometimes I get this problem (without any recompile, just entering the game level again).
The shader on the object is a vertex colored shader:
Shader " Vertex Colored" { Properties { _Color ("Main Color", Color) = (1,1,1,1) _MainTex ("Base (RGB)", 2D) = "white" {} }
SubShader { Pass {
ColorMaterial AmbientAndDiffuse
Lighting Off
SetTexture [_MainTex]
{
Combine texture * primary, texture * primary
}
SetTexture [_MainTex]
{
constantColor [_Color]
Combine previous * constant DOUBLE, previous * constant
}
}
}
Fallback "VertexLit", 1 }
Please let me know if there is anything I could do about this, to make it display right all the time.
Thanks a lot!
Answer by Eric5h5 · Jan 15, 2010 at 11:25 AM
UV animation fails when the coordinates get too far from the origin. Clamp them instead:
renderer.material.mainTextureOffset = new Vector2(0, offset%1);
Answer by Jaap Kreijkamp · Jan 12, 2010 at 11:35 PM
It could be that the renderer chooses a too low mipmap version, does the problem go away when you turn generating mipmaps for texture off? If not, could you provide screenshots so we can see what you mean?
Your answer
![](https://koobas.hobune.stream/wayback/20220611230754im_/https://answers.unity.com/themes/thub/images/avi.jpg)