I don’t know exactly what to call this but it has two textures. The first texture is just simple unlit and uses 1st set of UV’s. The one on top is and unlit decal and uses the 2nd set of UV’s.
The idea is to use this with a texture atlas so that the base texture can be decorated with transparent details from another part of the atlas.
If you use this shader on multiple objects, you can update both sets of UV’s on each object and all the objects will still batch.
My intention for making this shader was so I could have one master texture with several skins and several outfits which I would then use to create a cast of unique characters.
I’m actually having trouble just getting a decal shader to work on the iPhone.
I need a shader that will trick its material into rendering on Z above any coincident textures, such as on the surface the decal is applied to. I’ve tried the one on the Wiki and yours but the alpha doesn’t work on either.
Since your project works, I’m sure I’ll be able to figure out what I’m doing wrong by looking at it. Can’t wait to see it!
Don’t forget that you can use vertex colors; that will batch too. This was designed for a different purpose, but hopefully you can see how it might be beneficial; instead of multiplying the UV1 texture by one color, for every object, you can use any number of colors. It’s no big deal because you already needed separate meshed to account for the varying UV2 coordinates anyway. So those seams on your cubes at the edges that come from compression? They can disappear.
He hasn’t posted the project yet, but here’s what I’m observing:
There are both red and green cubes.
There is only one total draw call.
The shader multiplies the main texture by a solid color.
You can not have batching if two colors were to be used.
There are compression artifacts on the cube, the likes of which happen when you have two vastly different colors on large portions of a texture atlas.
This leads me to conclude that the first texture is a mix of red and green, and the color he’s multiplying them both by is white.
Vertex colors do not involve compression, so they will not exhibit the kind of artifacts we’re seeing above. As it is, the shader could even be simplified, if only a solid color with a decal is needed.
I just noticed that you put this shader in the Transparent queue. Move it out of there! It’s not blending with anything, and the iPhone will give you better performance if you keep it in the same queue as the rest of the opaque geometry, due to tile-based deferred rendering.