Changing scrolling textures on a plane using transparency

Hi,

Im trying to change between two textures on a plane with a scrolling effect and have hit a road block trying to achieve this.

My current attempt is to create a texture scrolling effect by setting the textures offset using something like this.

GetComponent<Renderer>().material.mainTextureOffset = new Vector2(F_Scroll_X, F_Scroll_Y);

I would then use the same method to move a second texture from a preset offset to 0,0 making it the visible texture.


I was hoping to find a method of having 2 materials on the mesh renderer and follow something like these steps

  1. First material is shown
  2. First Materials texture is offset to the side creating the scrolling effect
  3. The second materials texture would be starting at an offset, and by changing its offset to 0,0 It would scroll into place as the First material is scrolled out

The problem with this is the first material is not transparent when offset so it is still visible with the result been you see whatever wrapping mode the texture is using rather then the second material.

Im looking for a way to make the original texture appear transparent when its wrapped. Is this possible?

an alternate solution to achieve the same effect I considered was to have the two textures overlap but the original would somehow have an offset alpha channel that I could scroll to make it fully transparent, but I have no idea how I would go about achieving something like this. Is this possible with shaders and something I need to look further into?

Sorry if my question isn’t worded to well, but I hope it makes sense.
Thanks in advance for any help/advice,

This issue came down to my lack of knowledge around TextureWrapMode.Clamp and how it worked.

To solve my problem I had to make a 1 pixel border around the textures that was transparent, this pixel is what is used when the texture is wrapped using the Clamp Wrap mode.

Doing this allows the texture set at an offset of 0.5 to be displayed on half the plane whilst the other half is transparent. Using two materials setup like this I can move both offsets at the same time to scroll 1 texture in as the other is scrolled out.