Search Unity

Animating UV's?

Discussion in 'Shaders' started by noradninja, Apr 15, 2009.

  1. noradninja

    noradninja

    Joined:
    Nov 12, 2007
    Posts:
    420
    Code (csharp):
    1. Shader "TwoTex_Alpha_VertLit" {
    2. Properties {
    3.     _Color ("Main Color", Color) = (1,1,1,1)
    4.     _SpecColor ("Spec Color", Color) = (1,1,1,0)
    5.     _Emission ("Emmisive Color", Color) = (0,0,0,0)
    6.     _Shininess ("Shininess", Range (0.1, 1)) = 0.7
    7.     _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
    8.     _SubTex ("Base (RGB)", 2D) = "white" {}
    9. }
    10.  
    11. Category {
    12.     ZWrite Off
    13.     Alphatest Greater 0
    14.     Tags {Queue=Transparent}
    15.     Blend SrcAlpha OneMinusSrcAlpha
    16.     ColorMask RGB
    17.     SubShader {
    18.         Material {
    19.             Diffuse [_Color]
    20.             Ambient [_Color]
    21.             Shininess [_Shininess]
    22.             Specular [_SpecColor]
    23.             Emission [_Emission]   
    24.         }
    25.         Pass{
    26.             Lighting On
    27.             SeparateSpecular On
    28.             SetTexture [_SubTex] {
    29.                 Combine texture
    30.             }
    31.  
    32.                 }
    33.    
    34.     Pass{
    35.             Lighting On
    36.             SeparateSpecular On
    37.             SetTexture [_MainTex] {
    38.                 Combine texture * primary DOUBLE, texture * primary
    39.             }
    40.  
    41.         }
    42.     }
    43.    
    44. }
    45. }
    If I wanted to animate the UV's for the bottom texture (_MainTex) so it would scroll in say, a sine wave, how would I do it? would the bottom texture repeat automatically if it scrolled the UV's past the edge?
     
  2. antenna-tree

    antenna-tree

    Joined:
    Oct 30, 2005
    Posts:
    5,324
    Check out the flickering monitors in this example. I use a sine wave to scroll one of the textures in "interlaceRoller.js".