Offset Textures

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));
}

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.

1 Like

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.

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:

//In the Properties block
_Speed ("Offset Speed", float) = 1;

//Variable defines
float _Speed;

//Rest the the shader stuff

void surf (Input IN, inout SurfaceOutput o)
{
//Do stuff
          o.Albedo = tex2D (_MainTex, IN.uv_MainTex * (_Time.y *_Speed)).rgb;
/Do more stuff
      }
1 Like

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.

Here’s a few links:

http://wiki.unity3d.com/index.php/Shaders
http://en.wikibooks.org/wiki/Cg_Programming/Unity

Unity’s doc have a lot of info in them so don’t be afraid to just read through them all.

1 Like

oh, I’m new to this, didn’t know about those, thanks …

1 Like

No problem! :slight_smile: