Depth Mask Shader Issues with iPhone

The depth mask shader from the wiki dosen’t work on the iPhone , it has no effect on the output (altough it does work inside the editor even in iPhone graphic emulation).
can anyone help me fix it?

Shader "DepthMask"
{
    SubShader
    {
        // Turn off lighting, because it's expensive and the thing is supposed to be
        // invisible anyway.
 
        Lighting Off
 
        // Draw into the depth buffer in the usual way.  This is probably the default,
        // but it doesn't hurt to be explicit.
 
        ZTest LEqual
        ZWrite On
 
        // Don't draw the RGB colour channels, just the alpha channel.  This means
        // that nothing visible is drawn.  Ideally, I would have liked to set ColorMask
        // to draw nothing at all, but it doesn't seem to be possible to say anything
        // like ColorMask None.
 
        ColorMask A
 
        // Do nothing specific in the pass:
 
        Pass {}
    }
}

I want to use this too. Any help?

I think that it’s behaving inconsistently because it’s queue value equals geometry. Try this shader:

Shader "Depth Mask" {
	SubShader {
		Tags { "Queue" = "Background" }
		ColorMask A
		Pass { }
	}
}

That makes it the color of the background, instead of transparent. Can you point me to some documentation on “Queue” =? I haven’t found it yet.

Now I did.

http://unity3d.com/support/documentation/Components/SL-SubshaderTags.html

I got it working. :smile:

The problem is not with the DepthMask shader, although it can be simplified to this (note the zero instead of A):

Shader "Masked/Mask" {
	SubShader { 
		Tags { "Queue" = "Geometry+10" } 
		ColorMask 0
		Pass { } 
	}
}

The problem is that the Diffuse shader doesn’t work on the iPhone. (It falls back to the VertexLit shader.) So, I just cut and pasted some code from the VertexLit shader, and came up with this, which, when applied to the plane (water), works great!

Shader "Vertexy" {
	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" {}
	}

	SubShader {
		Tags {"Queue" = "Geometry+20" }
		Pass {
			Material 
			{
				Diffuse [_Color]
				Ambient [_Color]
				Shininess [_Shininess]
				Specular [_SpecColor]
				Emission [_Emission]
			} 
			Lighting On
			SeparateSpecular On
			SetTexture [_MainTex] 
				{Combine texture * primary DOUBLE, texture * primary}
		}
	}
}

I bet that could be improved upon quite easily by someone who really knows what they’re doing. :wink: