Decal shader for iPhone (single pass)

Seems to work pretty well although a lot of it was copy paste and trial and error for me! Hope it is of use to someone. YMMV

edit:
Also note that in the Warehouse/Occlusion demo there is a similar shader LightmapOnlyShader.shader which is used to make decals of windows on walls etc. but it doesn’t work with transparent decals. the following does work with transparent

Shader "iPhone/Decal" 
{

	Properties 
	{
		 _Color ("Main Color", Color) = (1,1,1,1)
		 _SpecColor ("Spec Color", Color) = (1,1,1,1)
		 _Emission ("Emmisive Color", Color) = (0,0,0,0)
		 _Shininess ("Shininess", Range (0.01, 1)) = 0.7
		 _MainTex ("Base (RGB)", 2D) = "white" {}
		 _DecalTex ("Decal (RGBA)", 2D) = "black" {}
	}

	SubShader 
	{

		Tags 
		{
			"Queue"="Transparent" 
			"IgnoreProjector"="True" 
			"RenderType"="Transparent"
		}

	    Material 
		{
			Diffuse [_Color]
			Ambient [_Color]
			Shininess [_Shininess]
			Specular [_SpecColor]
			Emission [_Emission]
	    }
	    Pass 
		{
	        BindChannels 
			{
				Bind "Vertex", vertex
				Bind "normal", normal
				Bind "texcoord1", texcoord0 // decal uses 2nd uv
				Bind "texcoord", texcoord1 // main uses 1st uv
			}
			Lighting On
			SeperateSpecular On
			SetTexture [_MainTex] {combine texture  * primary DOUBLE}
			SetTexture [_DecalTex] {combine texture lerp (texture) previous}
	    }
	}
}

has anyone tried this or can you improve it? Currently the lighting is only working for the main texture, not the decal texture. In my case, that turns out to be fine because the decal is the pips on dominos and it looks fine because the pips are always bright. however it could be good to have a decal shader with transparency that works correctly with lighting. maybe not possible on the iphone?

has any one had any problems using this shader on there Iphone or Touch?

Yet, I didn’t review the ShaderLab of Unity. But what I’m expecting is that:

  • I will use diffuse texture which have transparency
  • I will use a light map texture

Then it should use the Light Map texture for lit and diffuse for texturing. In the LightMapShaderOnly of Occlusion culling support Diffuse and a LightMap but it doesn’t work for transparency.

I used this Shader Code but I thing this not what I’m expecting. I think this will be a minor code addition in LightMapShaderOnly. Can anyone help?

Thanks