Search Unity

Offset Textures

Discussion in 'Shaders' started by razvanl, Mar 29, 2015.

  1. razvanl

    razvanl

    Joined:
    Feb 24, 2015
    Posts:
    8
    I'm using the SetTextureOffset to animate a material but I don't know what the names of the textures are, the documentation only mentions main,bump and cube but bump doesn't animate the normal map in the new shader, I want to offset the HeightMap and the Normal. Where can i find the names they are using?

    Here is the code - it's in the documentation

    void Update()
    {
    float offset = Time.time * OffsetSpeed;
    Rend.sharedMaterial.SetTextureOffset ("_BumpMap",new Vector2 (offset, 0));
    }
     
  2. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    You are talking about the new standard shaders right?

    Easiest way is to switch your inspector to Debug and look through the drop downs for the texture names. Otherwise you cab peek into the shader code(UnityStandardInput.cginc I think) or even the standard shader inspector script.

    I can't remember all of them off the top of my head, but the height map in _ParallaxTex or something like that.
     
    razvanl likes this.
  3. razvanl

    razvanl

    Joined:
    Feb 24, 2015
    Posts:
    8
    Thanks, found them, still don't know how to animate them properly but at least I know it's not because I don't call them well.
     
  4. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    Could do it in the shader itself(best place to do it really). Requires a custom shader though.

    _Time is a float4 that gives you various time values in a shader. _Time.y is what you want.

    Something like this:

    Code (CSharp):
    1.      
    2. //In the Properties block
    3. _Speed ("Offset Speed", float) = 1;
    4.  
    5. //Variable defines
    6. float _Speed;
    7.  
    8. //Rest the the shader stuff
    9.  
    10. void surf (Input IN, inout SurfaceOutput o)
    11. {
    12. //Do stuff
    13.           o.Albedo = tex2D (_MainTex, IN.uv_MainTex * (_Time.y *_Speed)).rgb;
    14. /Do more stuff
    15.       }
    16.  
     
    Last edited: Mar 29, 2015
    razvanl likes this.
  5. razvanl

    razvanl

    Joined:
    Feb 24, 2015
    Posts:
    8
    Thanks, that works quite well, is there any place I can learn a bit more about shader writing, unity's documentation doesn't shed much light on the subject.
     
  6. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    razvanl likes this.
  7. razvanl

    razvanl

    Joined:
    Feb 24, 2015
    Posts:
    8
    oh, I'm new to this, didn't know about those, thanks ... <starts reading>
     
    echo4papa likes this.
  8. echo4papa

    echo4papa

    Joined:
    Mar 26, 2015
    Posts:
    158
    No problem! :)