Hi everyone, I tried to write a GLSL shader that can translate the UV coordinates according to a vector. Here's what i've got so far : Code (csharp): Shader "MyShaders/TextureUvAnimation" { Properties { _MainTex("Texture Color", 2D) = "black" _DirectionUv("Texture scroll direction", Vector) = (1,1,0,0) } SubShader { Pass { GLSLPROGRAM uniform vec4 _Time; varying mediump vec2 uv; uniform mediump sampler2D _MainTex; uniform mediump vec4 _DirectionUv; #ifdef VERTEX void main() { uv = gl_MultiTexCoord0.xy + _Time.xx * _DirectionUv.xy; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; } #endif #ifdef FRAGMENT void main() { vec4 TextureColor = texture2D(_MainTex, uv); gl_FragColor = TextureColor; } #endif ENDGLSL } } } This is working as expected but now i'm wondering what will happen when the variable "uv" will reach its limit (since it is growing constantly as long as the _Time function goes on) ? If i want the texture to loop endlessly, i guess i need to reset the UV coordinates to their original position each time "_time.xx*_DirectionUv.xy" reaches 1 and this is where i'm stuck. Does anyone know how i could do that ?
meh11, in my experience, big values cause problems. Really easy to fix though: http://www.opengl.org/sdk/docs/manglsl/xhtml/fract.xml