x


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!

more ▼

asked Jan 12 '10 at 09:18 PM

BogdanDude gravatar image

BogdanDude
268 15 17 32

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

UV animation fails when the coordinates get too far from the origin. Clamp them instead:

renderer.material.mainTextureOffset = new Vector2(0, offset%1);
more ▼

answered Jan 15 '10 at 11:25 AM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

Right, good solution.

May 24 '10 at 12:53 PM ReJ
(comments are locked)
10|3000 characters needed characters left

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?

more ▼

answered Jan 12 '10 at 11:35 PM

Jaap Kreijkamp gravatar image

Jaap Kreijkamp
6.4k 20 26 70

The problem is there even if I turn off mipmaps

Jan 13 '10 at 09:45 AM BogdanDude
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x2188
x1998
x503

asked: Jan 12 '10 at 09:18 PM

Seen: 1863 times

Last Updated: Jan 12 '10 at 09:18 PM