I have a bunch of wall assets which look like this (quick screenshot, the full texture tiles):
I am trying to make the red parts animate and move horizontally, whereas the gray foreground parts stay static. Currently this is my solution:
- Use two planes with separate textures, one 0.001 units behind the other.
- For the foreground, use a cutout alpha shader to mask out the parts that should be red/animated.
- For the background, use a separate texture with a script that changes the X offset and time it so that it tiles.
While this works, it’s clumsy to use two planes for each wall section, it makes it harder to snap to a grid since it often snaps to the element with an offset, and it uses more draw calls through separate materials.
Is there a way to make a shader which has these properties?
- Use a diffuse map which is masked by its alpha channel.
- Use a second diffuse map which uses no alpha and always renders below the first one.
- Have the second diffuse map be targetable with a script so its offset can be animated separately.
This way I could do it all in a single plane with no (or minimal) extra draw calls and it’d all work much more elegantly. I’m not very knowledgeable on shaders and any material on this kind of approach I found online was either incomplete or obsolete at this point. This is a mobile-targeted game so optimally there’d only be a diffuse map and it’d be lit with a lightmap.