a shader that would scroll a multiline text from a texture

hm… found the way :slight_smile:

it has to be done in the frag part of the shader with something like that:

            fixed4 frag (v2f i) : SV_Target
            {
     
               if(i.uv.x > 1 )
               {
                  float tmp;
           
                  tmp = i.uv.x;
                  i.uv.x=frac(i.uv.x);
                  tmp=tmp-i.uv.x;
                  i.uv.y +=tmp*0.5;
                  if(i.uv.y > 1)
                  {
                     i.uv.y=1;
                     i.uv.x=1;
                  }
               }
     
                // sample the texture
                fixed4 col = tex2D(_MainTex, i.uv);
                // apply fog
                UNITY_APPLY_FOG(i.fogCoord, col);
                return col;
            }

for a base texture like this one:

giving this result:
4664123--438461--resoolt.gif

The only shitty part is the ‘gray’ limit generated by the non linear UV wrapping:
here:


looks like it’s generated by some floating point accuracy… ?
am not sure tho :-/

happy unitying !

EDIT: thanks to @bgolus for his explainations in this post: How to modify UV mapping in Shader?